<template>
  <view class="container">
    <!-- 进度指示器 -->
    <view class="progress-bar">
      <view v-for="(step, index) in steps" :key="index" class="progress-step" :class="{ 'active': currentStep >= index, 'completed': currentStep > index }">
        <view class="step-number">{{ index + 1 }}</view>
        <view class="step-title">{{ step.title }}</view>
      </view>
    </view>

    <!-- 步骤内容 -->
    <view class="step-content">
      <!-- 暂时移除u-form组件测试 -->
      <view class="form-container">
        
        <!-- 第一步：课程信息 -->
        <view v-if="currentStep === 0" class="step-container">
          <view class="step-header">
            <view class="step-icon">📖</view>
            <view class="step-title-main">课程信息设置</view>
            <view class="step-description">选择课程分类、具体课程、上课时间和地点等基础信息</view>
          </view>

          <!-- 删除调试信息，保持界面简洁 -->

          <view class="form-section">
            <view class="form-item">
              <view class="form-label required">课程分类</view>
              <view class="form-input-wrapper" @click="showCategorySelect = true">
                <view class="form-input" :class="{ 'placeholder': !form.courseCategoryName }">
                  {{ form.courseCategoryName || '请选择课程分类' }}
                </view>
                <u-icon class="form-arrow" name="arrow-down" size="24" color="#999"></u-icon>
              </view>
              <view v-if="errors.courseCategoryName" class="error-text">{{ errors.courseCategoryName }}</view>
            </view>
            
            <view class="form-item">
              <view class="form-label required">课程名称</view>
              <view class="form-input-wrapper" @click="checkAndShowCourseSelect">
                <view class="form-input" :class="{ 'placeholder': !form.courseName, 'disabled': !form.courseCategoryId }">
                  {{ form.courseName || '请选择课程名称' }}
                </view>
                <u-icon class="form-arrow" name="arrow-down" size="24" color="#999"></u-icon>
              </view>
              <view v-if="errors.courseName" class="error-text">{{ errors.courseName }}</view>
            </view>

            <!-- 上课时间选择 -->
            <view class="form-item">
              <view class="form-label required">上课时间</view>
              <view class="simple-input" @click="openCalendar('start')">
                {{ form.startTime || '请选择上课时间' }}
              </view>
              
              <!-- 快速时间选择 -->
              <view class="quick-time-select">
                <view class="quick-time-label">快速选择：</view>
                <view class="quick-time-buttons">
                  <view v-for="option in quickTimeOptions" :key="option.value" 
                        class="quick-time-btn" 
                        @click="selectQuickStartTime(option)">
                    {{ option.label }}
                  </view>
                </view>
              </view>
              <view v-if="errors.startTime" class="error-text">{{ errors.startTime }}</view>
            </view>

            <!-- 课程时长选择 -->
            <view class="form-item">
              <view class="form-label required">课程时长</view>
              
              <!-- 快速选择 -->
              <view class="quick-duration">
                <view class="quick-duration-label">快速选择：</view>
                <view class="duration-chips">
                  <view v-for="duration in quickDurations" :key="duration.value" 
                        class="duration-chip" 
                        :class="{ 'active': selectedDuration === duration.value }"
                        @click="selectQuickDuration(duration)">
                    {{ duration.label }}
                  </view>
                </view>
              </view>

              <!-- 自定义时长输入（只在选择自定义时显示） -->
              <view v-if="selectedDuration === 'custom'" class="custom-duration" style="margin-top: 16rpx;">
                <view class="duration-inputs">
                  <!-- 分钟输入 -->
                  <view class="duration-input-group">
                    <u-input 
                      v-model="form.duration_minutes" 
                      placeholder="分钟" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateCustomDuration"
                    />
                    <text class="duration-unit">分钟</text>
                  </view>

                  <!-- 小时输入（可选） -->
                  <view class="duration-input-group">
                    <u-checkbox 
                      v-model="showHoursDuration" 
                      @change="toggleHoursDuration"
                      active-color="#0dc160"
                      style="margin-right: 8rpx;"
                    >
                      小时
                    </u-checkbox>
                    <u-input 
                      v-if="showHoursDuration"
                      v-model="form.duration_hours" 
                      placeholder="小时" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateCustomDuration"
                    />
                    <text v-if="showHoursDuration" class="duration-unit">小时</text>
                  </view>
                </view>
              </view>
              
              <view v-if="errors.duration" class="error-text">{{ errors.duration }}</view>
            </view>
            
            <view class="form-item">
              <view class="form-label required">上课地点</view>
              <view class="form-input-wrapper" @click="chooseMap">
                <view class="form-input" :class="{ 'placeholder': !form.locationName }">
                  {{ form.locationName || '请选择上课地点' }}
                </view>
                <u-icon class="form-arrow" name="map-fill" size="24" color="#0dc160"></u-icon>
              </view>
              <view v-if="errors.locationName" class="error-text">{{ errors.locationName }}</view>
            </view>
          </view>
        </view>

        <!-- 第二步：班级信息 -->
        <view v-if="currentStep === 1" class="step-container">
          <view class="step-header">
            <view class="step-icon">📚</view>
            <view class="step-title-main">班级类型设置</view>
            <view class="step-description">选择适合的班级类型，不同类型有不同的特点和优势</view>
          </view>

          <!-- 班级类型选择 -->
          <view class="form-item">
            <view class="form-label required">班级类型</view>
            <view class="class-type-selector">
              <view 
                v-for="item in classList" 
                :key="item.value" 
                class="class-type-item"
                :class="{ 'class-type-active': form.classType === item.value }"
                @click="selectClassType(item)"
              >
                <view class="radio-circle">
                  <view class="radio-inner" v-if="form.classType === item.value"></view>
                </view>
                <view class="class-type-content">
                  <view class="class-type-name">{{ item.label }}</view>
                  <view class="class-type-subtitle">
                    <text v-if="item.value === '3'">按周期付费 • 可退课退班</text>
                    <text v-if="item.value === '4'">一次性付费 • 课程顺延</text>
                  </view>
                </view>
              </view>
            </view>
            <view v-if="errors.classType" class="error-text">{{ errors.classType }}</view>
          </view>

          <!-- 班级类型说明 -->
          <view class="class-type-description">
            <view v-if="form.classType === '3'" class="type-desc">
              <view class="desc-title">📅 周期班详细说明</view>
              <view class="desc-content">
                <view class="desc-section">
                  <view class="desc-section-title">💰 付费模式</view>
                  <text>• 按周期进行付费，每个周期独立结算</text>
                  <text>• 支持开通免密代扣功能，自动续费</text>
                  <text>• 可随时关闭自动续费功能</text>
                </view>
                <view class="desc-section">
                  <view class="desc-section-title">📚 上课方式</view>
                  <text>• 固定时间上课，培养良好学习习惯</text>
                  <text>• 适合长期系统性学习计划</text>
                  <text>• 需要设置上课星期和总周期数</text>
                </view>
                <view class="desc-section">
                  <view class="desc-section-title">🔄 退课政策</view>
                  <text>• 可提前手动退课和退班</text>
                  <text>• 退款剩余未上课程的金额</text>
                  <text>• 已错过的课程不会顺延，也不退款</text>
                </view>
              </view>
            </view>
            <view v-if="form.classType === '4'" class="type-desc">
              <view class="desc-title">🎯 定制班详细说明</view>
              <view class="desc-content">
                <view class="desc-section">
                  <view class="desc-section-title">💰 付费模式</view>
                  <text>• 一次性付清全部课程费用</text>
                  <text>• 不支持分期付款或代扣功能</text>
                  <text>• 付费后不允许退款</text>
                </view>
                <view class="desc-section">
                  <view class="desc-section-title">📚 上课方式</view>
                  <text>• 灵活安排上课时间</text>
                  <text>• 个性化定制教学内容</text>
                  <text>• 适合有特殊需求的学员</text>
                </view>
                <view class="desc-section">
                  <view class="desc-section-title">🔄 课程政策</view>
                  <text>• 没有上的课程可以自动顺延</text>
                  <text>• 不支持退课退班退款</text>
                  <text>• 课程有效期内可灵活安排</text>
                </view>
              </view>
            </view>
          </view>

          <!-- 周期班特殊设置 -->
          <template v-if="form.classType == 3 || form.classType == 4">
            <view class="form-item">
              <view class="form-label required">上课星期</view>
              <view class="form-label-desc">请选择每周的上课时间</view>
              
              <!-- 优化的星期选择器 - 兼容移动端 -->
              <view class="weekdays-selector">
                <view 
                  v-for="(day, index) in weekList" 
                  :key="index" 
                  class="weekday-option"
                  :class="{ 'weekday-selected': selectedWeekdays[index] }"
                  @click="toggleWeekday(index)"
                >
                  <view class="weekday-circle">
                    <view class="weekday-check" v-if="selectedWeekdays[index]">✓</view>
                  </view>
                  <view class="weekday-text">{{ day.text }}</view>
                </view>
              </view>
              
              <!-- 选择结果显示 -->
              <view v-if="form.weekDayName" class="selected-weekdays">
                <text class="selected-label">已选择：</text>
                <text class="selected-value">{{ form.weekDayName }}</text>
              </view>
              
              <view v-if="errors.weekdays" class="error-text">{{ errors.weekdays }}</view>
            </view>
            
            <view class="form-item">
              <view class="form-label required">总周期数</view>
              <view class="form-input-wrapper">
                <u-input 
                  v-model="form.totalCycles" 
                  placeholder="请输入总周期数（如：8表示8周）" 
                  type="number" 
                  :border="false"
                  class="form-input-field"
                />
              </view>
              <view v-if="errors.totalCycles" class="error-text">{{ errors.totalCycles }}</view>
            </view>
          </template>
        </view>

        <!-- 第三步：成班设置 -->
        <view v-if="currentStep === 2" class="step-container">
          <view class="step-header">
            <view class="step-icon">⏰</view>
            <view class="step-title-main">成班时间与人数</view>
            <view class="step-description">设置成班截止时间和人数要求，合理的设置有助于提高成班成功率</view>
          </view>

          <!-- 优化的成班时间设置 -->
          <view class="setting-group">
            <view class="setting-title">
              <view class="title-icon">👥</view>
              <text>普通班设置</text>
            </view>
            <view class="setting-row">
              <view class="setting-label">成班截止时间</view>
              <view class="form-label-desc">设置上课前多长时间停止报名</view>
              
              <!-- 快速选择（辅助功能） -->
              <view class="deadline-quick-select">
                <view class="deadline-chips">
                  <view v-for="time in quickDeadlineTimes" :key="time.value" 
                        class="deadline-chip" 
                        :class="{ 'active': selectedNormalDeadline === time.value }"
                        @click="selectQuickDeadline('normal', time)">
                    {{ time.label }}
                  </view>
                </view>
              </view>

              <!-- 自定义截止时间输入（只在选择自定义时显示） -->
              <view v-if="selectedNormalDeadline === 'custom'" class="custom-deadline" style="margin-top: 16rpx;">
                <view class="deadline-inputs">
                  <!-- 小时输入 -->
                  <view class="deadline-input-group">
                    <u-input 
                      v-model="form.before_class_hours" 
                      placeholder="小时" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateNormalDeadline"
                    />
                    <text class="deadline-unit">小时</text>
                  </view>

                  <!-- 天数输入（可选） -->
                  <view class="deadline-input-group">
                    <u-checkbox 
                      v-model="showNormalDays" 
                      @change="toggleNormalDays"
                      active-color="#0dc160"
                      style="margin-right: 8rpx;"
                    >
                      天数
                    </u-checkbox>
                    <u-input 
                      v-if="showNormalDays"
                      v-model="form.before_class_days" 
                      placeholder="天数" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateNormalDeadline"
                    />
                    <text v-if="showNormalDays" class="deadline-unit">天</text>
                  </view>
                </view>
                
                <!-- 显示总计时间 -->
                <view v-if="normalDeadlineDisplay" class="deadline-display">
                  <text class="deadline-display-label">截止时间：</text>
                  <text class="deadline-display-value">上课前{{ normalDeadlineDisplay }}</text>
                </view>
              </view>
            </view>
            
            <view class="setting-row">
              <view class="setting-label">人数范围</view>
              <view class="number-range">
                <u-input v-model="form.minParticipants" placeholder="最少" type="number" :border="true" />
                <text class="range-separator">-</text>
                <u-input v-model="form.maxParticipants" placeholder="最多" type="number" :border="true" />
                <text class="unit">人</text>
              </view>
            </view>
          </view>

          <view class="setting-group">
            <view class="setting-title">
              <view class="title-icon">💎</view>
              <text>精品班设置</text>
            </view>
            <view class="setting-row">
              <view class="setting-label">成班截止时间</view>
              <view class="form-label-desc">精品班截止时间应早于普通班</view>
              
              <!-- 快速选择（辅助功能） -->
              <view class="deadline-quick-select">
                <view class="deadline-chips">
                  <view v-for="time in quickDeadlineTimesVip" :key="time.value" 
                        class="deadline-chip" 
                        :class="{ 'active': selectedVipDeadline === time.value }"
                        @click="selectQuickDeadline('vip', time)">
                    {{ time.label }}
                  </view>
                </view>
              </view>

              <!-- 自定义截止时间输入（只在选择自定义时显示） -->
              <view v-if="selectedVipDeadline === 'custom'" class="custom-deadline" style="margin-top: 16rpx;">
                <view class="deadline-inputs">
                  <!-- 小时输入 -->
                  <view class="deadline-input-group">
                    <u-input 
                      v-model="form.boutique_before_class_hours" 
                      placeholder="小时" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateVipDeadline"
                    />
                    <text class="deadline-unit">小时</text>
                  </view>

                  <!-- 天数输入（可选） -->
                  <view class="deadline-input-group">
                    <u-checkbox 
                      v-model="showVipDays" 
                      @change="toggleVipDays"
                      active-color="#0dc160"
                      style="margin-right: 8rpx;"
                    >
                      天数
                    </u-checkbox>
                    <u-input 
                      v-if="showVipDays"
                      v-model="form.boutique_before_class_days" 
                      placeholder="天数" 
                      type="number" 
                      :border="true"
                      style="width: 120rpx;"
                      @input="updateVipDeadline"
                    />
                    <text v-if="showVipDays" class="deadline-unit">天</text>
                  </view>
                </view>
                
                <!-- 显示总计时间 -->
                <view v-if="vipDeadlineDisplay" class="deadline-display">
                  <text class="deadline-display-label">截止时间：</text>
                  <text class="deadline-display-value">上课前{{ vipDeadlineDisplay }}</text>
                </view>
              </view>
            </view>
            
            <view class="setting-row">
              <view class="setting-label">最低人数</view>
              <view class="number-input">
                <u-input v-model="form.boutiqueMinUsers" placeholder="最少人数" type="number" :border="true" />
                <text class="unit">人</text>
              </view>
            </view>
          </view>

          <!-- 智能提示 -->
          <view class="smart-tips">
            <view class="tip-item">
              <view class="tip-icon">💡</view>
              <view class="tip-text">建议精品班截止时间比普通班提前1-2小时，确保有足够时间进行转换</view>
            </view>
          </view>
        </view>

        <!-- 第四步：高级设置（可选） -->
        <view v-if="currentStep === 3" class="step-container">
          <view class="step-header">
            <view class="step-icon">⚙️</view>
            <view class="step-title-main">高级设置</view>
            <view class="step-description">可选的高级功能设置，帮助提升课程吸引力和运营效率</view>
          </view>

          <!-- 班级级别配置 -->
          <view class="setting-group">
            <view class="setting-title">
              <view class="title-icon">🏫</view>
              <text>班级功能配置</text>
            </view>
            
            <view class="setting-item">
              <view class="setting-info">
                <view class="setting-label">启用虚拟人数</view>
                <view class="setting-desc">开启后可设置虚拟报名人数，提升课程吸引力</view>
              </view>
              <u-switch v-model="form.virtualEnabled" active-color="#0dc160" @change="onVirtualEnabledChange"></u-switch>
            </view>
            
            <view class="setting-item">
              <view class="setting-info">
                <view class="setting-label">启用优惠券</view>
                <view class="setting-desc">允许学员使用优惠券报名课程</view>
              </view>
              <u-switch v-model="form.couponEnabled" active-color="#0dc160"></u-switch>
            </view>
            

            
            <view class="setting-item">
              <view class="setting-info">
                <view class="setting-label">允许自动代扣</view>
                <view class="setting-desc">周期班可开启自动续费功能</view>
              </view>
              <u-switch v-model="form.autoDeductionEnabled" active-color="#0dc160" :disabled="form.classType !== '3'" @change="onAutoDeductionChange"></u-switch>
            </view>
          </view>

          <!-- 课程定价配置 -->
          <view class="setting-group">
            <view class="setting-title">
              <view class="title-icon">💰</view>
              <text>定价策略配置</text>
            </view>
            
            <view class="setting-item" :class="{ 'setting-disabled': form.classType === '4' }">
              <view class="setting-info">
                <view class="setting-label">启用新人价</view>
                <view class="setting-desc">
                  {{ form.classType === '4' ? '定制班不支持新人价' : '新用户首次报名可享受优惠价格' }}
                </view>
              </view>
              <u-switch 
                v-model="form.newUserPriceEnabled" 
                :disabled="form.classType === '4'"
                active-color="#0dc160" 
                @change="syncNewbiePriceEnabled"
              ></u-switch>
            </view>
            
            <view class="setting-item">
              <view class="setting-info">
                <view class="setting-label">启用权益价</view>
                <view class="setting-desc">会员用户可享受专属权益价格</view>
              </view>
              <u-switch v-model="form.benefitPriceEnabled" active-color="#0dc160"></u-switch>
            </view>
            
            <view class="setting-item" :class="{ 'setting-disabled': form.classType === '4' }">
              <view class="setting-info">
                <view class="setting-label">启用新品价</view>
                <view class="setting-desc">
                  {{ form.classType === '4' ? '定制班不支持新品价' : '新课程推广期间的特殊优惠价格' }}
                </view>
              </view>
              <u-switch 
                v-model="form.newProductPriceEnabled" 
                :disabled="form.classType === '4'"
                active-color="#0dc160"
              ></u-switch>
            </view>
          </view>

          <!-- 配置说明 -->
          <view class="config-tips">
            <view class="tips-title">📋 配置说明</view>
            <view class="tips-content">
              <text>• 班级功能配置：影响整个班级的功能开关</text>
              <text>• 定价策略配置：每个课程排期都会继承这些设置</text>
              <text>• 自动代扣：仅周期班支持，定制班不可用</text>
              <text>• 虚拟人数：开启后可在班级管理中设置虚拟报名数</text>
              <text>• 免单功能：运动主理人和运动推荐官自动启用一个免单名额</text>
            </view>
          </view>
          
          <view class="completion-tips">
            <view class="completion-icon">🎉</view>
            <view class="completion-text">
              <view class="completion-title">即将完成设置</view>
              <view class="completion-desc">点击"创建拼班"即可发布您的课程</view>
            </view>
          </view>
        </view>

      </view>
    </view>

    <!-- 底部操作按钮 -->
    <view class="action-buttons">
      <view v-if="currentStep > 0" class="btn btn-secondary" @click="prevStep">上一步</view>
      <view v-if="currentStep < steps.length - 1" class="btn btn-primary" @click="nextStep">下一步</view>
      <view v-if="currentStep === steps.length - 1" class="btn btn-primary" @click="submitGroupClass">创建拼班</view>
    </view>

    <!-- 其他弹窗组件保持不变 -->
    <!-- 使用u-picker替换u-datetime-picker，参考index.vue的成功方案 -->
    <u-picker 
      mode="time" 
      v-model="showCalendar" 
      @confirm="calendarConfirm" 
      :params="timeParams"
      :default-time="form.startTime"
    ></u-picker>
    
    <u-select v-model="showCategorySelect" :list="courseCategories" @confirm="selectCategoryConfirm" mode="single-column"></u-select>
    <u-select v-model="showCourseSelect" :list="courseList" @confirm="selectCourseConfirm" mode="single-column"></u-select>
    
    <u-popup mode="top" width="100%" height="100%" v-model="showMap" @open="openMap">
      <map-selector ref="mapSelector" @select="handlerSelectMap" @cancel="showMap = false" />
    </u-popup>

    <!-- 成功弹窗 -->
    <u-popup v-model="showSuccessPopup" mode="center" width="80%" :maskCloseAble="false">
      <view class="success-popup">
        <view class="success-icon">
          <u-icon name="checkmark-circle" color="#0dc160" size="64"></u-icon>
        </view>
        <view class="success-title">创建成功</view>
        <view class="success-desc">您已成功发起拼班，请选择下一步操作</view>
        <view class="success-actions">
          <view class="success-btn primary" @click="goToInviteTeacher">
            {{ isSingleCourse ? '去邀请陪伴师' : '去排课' }}
          </view>
          <view class="success-btn default" @click="goToHomePage">进入主页</view>
          <view class="success-btn link" @click="continueCreateClass">继续发起拼班</view>
        </view>
      </view>
    </u-popup>
  </view>
</template>
<script>
import { createGroupClass, getCourseCategories, getCoursesByCategory, getClassTypes, getClassDeadlineConfig, getGroupClassBusinessConfig } from '@/api/class_share';
import Cache from '@/utils/cache';
import mapSelector from '@/components/map/index.vue';
import { baseURL } from '@/config/app.js';

// 日期格式化函数（来自StepOne.vue）
function formatDate({
  year,
  month,
  day,
  timestamp
}) {
  const date = new Date(timestamp * 1000);
  const hours = date.getHours().toString().padStart(2, '0');
  const minutes = date.getMinutes().toString().padStart(2, '0');
  const seconds = date.getSeconds().toString().padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

export default {
  components: {
    mapSelector,
  },
  computed: {
    // 格式化显示开始时间，去掉秒数
    displayStartTime() {
      if (!this.form.startTime) {
        return '';
      }
      // 将 YYYY-MM-DD HH:mm:ss 格式转换为 YYYY-MM-DD HH:mm
      return this.form.startTime.replace(/:\d{2}$/, '');
    },
    
    // 普通班截止时间显示
    normalDeadlineDisplay() {
      const days = parseInt(this.form.before_class_days) || 0;
      const hours = parseInt(this.form.before_class_hours) || 0;
      
      if (days === 0 && hours === 0) {
        return '';
      }
      
      let display = '';
      if (days > 0) {
        display += `${days}天`;
      }
      if (hours > 0) {
        display += `${hours}小时`;
      }
      
      return display;
    },
    
    // 精品班截止时间显示
    vipDeadlineDisplay() {
      const days = parseInt(this.form.boutique_before_class_days) || 0;
      const hours = parseInt(this.form.boutique_before_class_hours) || 0;
      
      if (days === 0 && hours === 0) {
        return '';
      }
      
      let display = '';
      if (days > 0) {
        display += `${days}天`;
      }
      if (hours > 0) {
        display += `${hours}小时`;
      }
      
      return display;
    }
  },
  data() {
    return {
      show: false,
      showMap: false,
      courseList: [],
      classList: [
        {
          label: '周期班',
          value: '3',
        },
        {
          label: '定制班',
          value: '4',
        },
      ],
      multiple: false,
      // 周期班\定制班
      weekList: [
        { value: '1', text: '周一' },
        { value: '2', text: '周二' },
        { value: '3', text: '周三' },
        { value: '4', text: '周四' },
        { value: '5', text: '周五' },
        { value: '6', text: '周六' },
        { value: '7', text: '周日' },
      ],
      form: {
        classType: '3', // 默认选择周期班
        className: '周期班',
        courseCategoryId: '',
        courseCategoryName: '',
        courseName: '',
        courseId: '',
        coachId: '',
        startTime: '',
        duration: '',
        duration_hours: '', // 默认为空
        duration_minutes: '', // 默认为空
        enrollmentDeadline: '',
        before_class_hours: '3', // 默认3小时
        before_class_minutes: '0', // 默认0分钟
        before_class_days: '', // 普通班天数（新增）
        boutique_before_class_hours: '2', // 默认2小时
        boutique_before_class_minutes: '0', // 默认0分钟
        boutique_before_class_days: '', // 精品班天数（新增）
        beforeClassTime: '3', // 普通班快速选择值
        boutiqueBeforeClassTime: '2', // 精品班快速选择值
        boutiqueMinUsers: '1', // 精品班最低成班人数
        locationName: '',
        location: {
          name: '',
          province: '',
          city: '',
          district: '',
          address: '',
          longitude: '',
          latitude: '',
        },
        weekdays: [],
        weekDayName: '',
        totalCycles: '',
        minParticipants: '3',
        maxParticipants: '20',
        // 高级配置开关（对应tx_group_class表）
        virtualEnabled: true, // 是否启用虚拟人数（默认启用）
        couponEnabled: true, // 是否启用优惠券（默认启用）  
        newUserPriceEnabled: true, // 是否启用新人价（默认启用）
        autoDeductionEnabled: false, // 是否允许自动代扣（默认关闭）
        // 课程排期配置（对应tx_course_schedule表）
        newbiePriceEnabled: true, // 是否启用新人价（排课级别，默认启用）
        benefitPriceEnabled: true, // 是否启用权益价（默认启用）
        newProductPriceEnabled: false, // 是否启用新品价（默认关闭）
        // 兼容老字段
        virtualParticipants: false, // 启用虚拟人数（已废弃，使用virtualEnabled）
        newPriceEnabled: false, // 启用新人价（已废弃，使用newUserPriceEnabled）
        isFree: false, // 免单学员
        freeStudentId: '', // 免单学员ID
        freeStudentName: '',
        paymentType: '', // 支付类型:1=单次支付,2=周期代扣,3=全款支付
        status: 0, // 状态:0=待成班,1=已成班,2=进行中,3=已结束,4=已取消
        minIncome: '',
        maxIncome: '',
      },
      calendarType: '',
      showCalendar: false,
      mode: 'datetime', // 改为 datetime 模式
      showSelect: false,
      selectList: [],
      selectType: 1,
      rules: {
        classType: [
          {
            required: true,
            message: '请选择班级类型',
            trigger: ['change', 'blur'],
          },
        ],
        startTime: [
          {
            required: true,
            message: '请选择上课时间',
            trigger: ['change', 'blur'],
          },
        ],
        courseCategory: [
          {
            required: true,
            message: '请选择课程分类',
            trigger: ['change', 'blur'],
          },
        ],
        courseName: [
          {
            required: true,
            message: '请选择课程名称',
            trigger: ['change', 'blur'],
          },
        ],
        locationName: [
          {
            required: true,
            message: '请选择上课地点',
            trigger: ['change', 'blur'],
          },
        ],
        minParticipants: [
          {
            required: true,
            message: '请输入最小人数',
            trigger: ['change', 'blur'],
          },
        ],
        maxParticipants: [
          {
            required: true,
            message: '请输入最大人数',
            trigger: ['change', 'blur'],
          },
        ],
      },
      showHoursDuration: false, // 默认不显示小时输入框
      showDaysDuration: false,
      showBeforeClassHours: true, // 默认显示小时
      showBoutiqueBeforeClassHours: true, // 默认显示小时
      selectedWeekdays: [false, false, false, false, false, false, false],
      // 课程分类列表
      courseCategories: [],
      // 当前分类下的课程列表
      courseList: [],
      // 选择器控制
      showCategorySelect: false,
      showCourseSelect: false,
      mapUrl: baseURL + '/admin/map',
      showSuccessPopup: false,
      createdClassId: null,
      scheduleId: null,
      // 课程次数相关信息
      totalCourses: 0,           // 总课程次数
      isSingleCourse: false,     // 是否为单课程
      deadlineConfig: {
        min_before_class_hours: 3,
        min_boutique_before_class_hours: 2,
        min_student_count_vip: 1
      },
      scheduleConfig: {
        validation: {
          enabled: true,
          show_warning_modal: true,
          allow_next_week_start: true
        },
        interval: {
          min_hours: 2
        },
        advance: {
          max_advance_days: 90,
          min_advance_hours: 24,
          allow_same_day: false
        },
        skip_expired: {
          enabled: true
        }
      },
      currentStep: 0, // 确保初始值为数字0
      steps: [
        { title: '课程信息' },
        { title: '班级信息' },
        { title: '成班设置' },
        { title: '高级设置' },
      ],
      quickDurations: [
        { value: '0.5', label: '30分钟' },
        { value: '1', label: '1小时' },
        { value: '1.5', label: '1.5小时' },
        { value: '2', label: '2小时' },
        { value: '3', label: '3小时' },
        { value: 'custom', label: '自定义' },
      ],
      selectedDuration: '', // 默认不选择任何预设时长
      quickTimes: [
        { value: '1', label: '1小时' },
        { value: '2', label: '2小时' },
        { value: '3', label: '3小时' },
        { value: '4', label: '4小时' },
        { value: '6', label: '6小时' },
      ],
      quickTimesVip: [
        { value: '1', label: '1小时' },
        { value: '2', label: '2小时' },
        { value: '3', label: '3小时' },
        { value: '4', label: '4小时' },
      ],
      quickTimeOptions: [
        { value: 'today_afternoon', label: '今天下午' },
        { value: 'today_evening', label: '今天晚上' },
        { value: 'tomorrow_morning', label: '明天上午' },
        { value: 'tomorrow_afternoon', label: '明天下午' },
        { value: 'weekend', label: '本周末' },
        { value: 'custom', label: '自定义时间' },
      ],
      timeParams: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: false,
      },
      // 表单验证错误信息
      errors: {},
      // 自动保存定时器
      autoSaveInterval: null,
      // 截止时间选择器相关字段
      selectedNormalDeadline: '3', // 普通班默认选择3小时
      selectedVipDeadline: '2', // 精品班默认选择2小时
      showNormalDays: false, // 普通班是否显示天数输入
      showVipDays: false, // 精品班是否显示天数输入
      quickDeadlineTimes: [
        { value: '3', label: '3小时' },
        { value: '4', label: '4小时' },
        { value: '5', label: '5小时' },
        { value: '6', label: '6小时' },
        { value: '12', label: '12小时' },
        { value: '24', label: '1天' },
        { value: 'custom', label: '自定义' },
      ],
      quickDeadlineTimesVip: [
        { value: '2', label: '2小时' },
        { value: '3', label: '3小时' },
        { value: '4', label: '4小时' },
        { value: '5', label: '5小时' },
        { value: '6', label: '6小时' },
        { value: '12', label: '12小时' },
        { value: '24', label: '1天' },
        { value: 'custom', label: '自定义' },
      ],
    };
  },
  onReady() {
    // Cache.set('COUCHID', '');
    // this.$refs.uForm.setRules(this.rules);
    console.log('onReady - currentStep:', this.currentStep);
    console.log('onReady - form:', this.form);
    console.log('onReady - classList:', this.classList);
  },
  mounted() {
    console.log('mounted - currentStep:', this.currentStep);
    console.log('mounted - isDevelopmentMode:', this.isDevelopmentMode);
  },
  onLoad(options) {
    console.log('页面加载参数:', options);
    
    // 初始化数据同步检查
    this.checkDataSync();
    
    // 设置地图URL
    // this.mapUrl = `${baseURL}/h5/#/pages/map/index`;
    // 修正地图URL，与活动页面保持一致
    this.mapUrl = baseURL + '/admin/map';
    console.log('地图URL:', this.mapUrl);

    // 监听地图选择事件
    uni.$on('locationConfirm', this.handlerSelectMap);

    // 获取课程分类
    this.fetchCourseCategories();
    
    // 获取班级类型
    this.fetchClassTypes();
    
    // 获取拼班时长配置
    this.fetchDeadlineConfig();
    
    // 获取拼班业务配置
    this.fetchBusinessConfig();
    
    // 获取调度配置
    this.fetchScheduleConfig();
    
    // 初始化页面状态
    this.initializePageState();
    
    // 设置默认高级配置开关
    this.setDefaultAdvancedConfig();
  },
  onUnload() {
    // 清理自动保存定时器
    if (this.autoSaveInterval) {
      clearInterval(this.autoSaveInterval);
      this.autoSaveInterval = null;
    }
    
    // 移除事件监听
    uni.$off('locationConfirm');
    
    console.log('页面卸载，已清理资源');
  },
  created() {
    console.log('开始加载数据');
  },
  methods: {
    // 切换开发模式
    toggleDevelopmentMode() {
      this.isDevelopmentMode = !this.isDevelopmentMode;
      
      if (this.isDevelopmentMode) {
        uni.showToast({
          title: '已切换到开发模式',
          icon: 'none',
          duration: 1500
        });
      } else {
        uni.showToast({
          title: '已切换到真实API',
          icon: 'none',
          duration: 1500
        });
        // 重新获取数据
        this.fetchCourseCategories();
        this.fetchClassTypes();
        this.fetchDeadlineConfig();
      }
    },
    
    // 班级类型选择
    selectClassType(item) {
      this.form.classType = item.value;
      this.form.className = item.label;
      
      // 触发班级类型变化的配置联动处理
      this.onClassTypeChange();
    },
    
    // 打开日历选择器
    openCalendar(type) {
      console.log('=== 打开时间选择器 ===');
      console.log('传入的type:', type);
      console.log('设置calendarType前:', this.calendarType);
      
      this.calendarType = type;
      console.log('设置calendarType后:', this.calendarType);
      
      // 调试currentPickerTime
      console.log('当前form.startTime:', this.form.startTime);
      console.log('传递给u-picker的default-time:', this.form.startTime);
      
      // 如果没有设置时间，设置一个默认时间
      if (!this.form.startTime && type === 'start') {
        const now = new Date();
        const year = now.getFullYear();
        const month = String(now.getMonth() + 1).padStart(2, '0');
        const day = String(now.getDate()).padStart(2, '0');
        const hours = String(now.getHours()).padStart(2, '0');
        const minutes = String(now.getMinutes()).padStart(2, '0');
        
        this.form.startTime = `${year}-${month}-${day} ${hours}:${minutes}:00`;
        console.log('设置默认时间:', this.form.startTime);
      }
      
      console.log('设置showCalendar前:', this.showCalendar);
      this.showCalendar = true;
      console.log('设置showCalendar后:', this.showCalendar);
      console.log('=== 时间选择器应该已显示 ===');
    },
    
    // 时间选择确认（更新为u-datetime-picker格式）
    handleTimeConfirm(e) {
      console.log('=== u-datetime-picker 时间选择器回调开始 ===');
      console.log('参数e:', e);
      console.log('参数类型:', typeof e);
      console.log('参数属性:', e ? Object.keys(e) : 'e为空');
      console.log('calendarType:', this.calendarType);
      
      if (this.calendarType === 'start') {
        console.log('进入start分支');
        try {
          // u-datetime-picker返回格式: { year, month, day, hour, minute }
          console.log('调用格式化前...');
          const formattedTime = `${e.year}-${e.month.padStart(2, '0')}-${e.day.padStart(2, '0')} ${e.hour.padStart(2, '0')}:${e.minute.padStart(2, '0')}:00`;
          console.log('格式化后的时间:', formattedTime);
          
          this.form.startTime = formattedTime;
          console.log('设置到form.startTime:', this.form.startTime);
          console.log('displayStartTime计算结果:', this.displayStartTime);
          
          uni.showToast({
            title: '上课时间已设置',
            icon: 'success',
            duration: 1500
          });
        } catch (error) {
          console.error('处理时间时出错:', error);
          console.log('错误的参数e:', JSON.stringify(e));
        }
      } else {
        console.log('calendarType不是start:', this.calendarType);
      }
      
      console.log('关闭时间选择器');
      this.showCalendar = false;
      console.log('=== u-datetime-picker 时间选择器回调结束 ===');
    },
    
    // 快速选择时长
    selectQuickDuration(duration) {
      console.log('选择时长:', duration);
      this.selectedDuration = duration.value;
      
      if (duration.value !== 'custom') {
        // 选择预设时长
        const totalHours = parseFloat(duration.value);
        const hours = Math.floor(totalHours);
        const minutes = Math.round((totalHours - hours) * 60);
        
        if (hours >= 1) {
          // 有小时数，设置小时和分钟，显示小时输入框
          this.form.duration_hours = hours.toString();
          this.form.duration_minutes = minutes.toString();
          this.showHoursDuration = true;
        } else {
          // 小于1小时，只设置分钟数
          this.form.duration_hours = '';
          this.form.duration_minutes = Math.round(totalHours * 60).toString();
          this.showHoursDuration = false;
        }
        
        // 更新时长显示
        this.updateCustomDuration();
        
        // 清除时长相关错误
        this.clearError('duration');
        
        uni.showToast({
          title: `已选择${duration.label}`,
          icon: 'success',
          duration: 1000
        });
      } else {
        // 选择自定义时长，保持当前数据不变，只是显示输入框
        // 如果当前没有任何数据，设置默认值
        if (!this.form.duration_hours && !this.form.duration_minutes) {
          this.form.duration_minutes = '30'; // 默认30分钟
          this.form.duration_hours = '';
          this.showHoursDuration = false;
        } else {
          // 保持当前数据，根据是否有小时数决定是否显示小时输入框
          this.showHoursDuration = !!(this.form.duration_hours && parseInt(this.form.duration_hours) > 0);
        }
        
        // 更新时长显示
        this.updateCustomDuration();
        
        uni.showToast({
          title: '可以自定义调整时长',
          icon: 'none',
          duration: 1500
        });
      }
    },
    
    // 快速选择时间
    selectQuickTime(type, time) {
      console.log('选择快速时间:', type, time);
      
      if (type === 'normal') {
        this.form.beforeClassTime = time.value;
        this.form.before_class_hours = time.value;
        this.form.before_class_minutes = '0';
      } else if (type === 'vip') {
        this.form.boutiqueBeforeClassTime = time.value;
        this.form.boutique_before_class_hours = time.value;
        this.form.boutique_before_class_minutes = '0';
      }
      
      uni.showToast({
        title: `已设置${time.label}`,
        icon: 'success',
        duration: 1000
      });
    },
    
    // 下一步
    nextStep() {
      console.log('下一步，当前步骤:', this.currentStep);
      
      // 验证当前步骤
      if (!this.validateCurrentStep()) {
        // 显示第一个错误信息
        const firstError = Object.values(this.errors)[0];
        if (firstError) {
          uni.showToast({
            title: firstError,
            icon: 'none',
            duration: 2000
          });
        }
        return;
      }
      
      if (this.currentStep < this.steps.length - 1) {
        this.currentStep++;
        this.autoSave(); // 自动保存进度
        
        uni.showToast({
          title: `进入${this.steps[this.currentStep].title}`,
          icon: 'success',
          duration: 1000
        });
      }
    },
    
    // 上一步
    prevStep() {
      console.log('上一步，当前步骤:', this.currentStep);
      
      if (this.currentStep > 0) {
        this.currentStep--;
        this.autoSave(); // 自动保存进度
      }
    },
    
    // 自动保存草稿
    autoSave() {
      try {
        uni.setStorageSync('draft_class_form', JSON.stringify(this.form));
        uni.setStorageSync('draft_step', this.currentStep);
        console.log('自动保存草稿成功');
      } catch (e) {
        console.log('自动保存失败:', e);
      }
    },
    
    // 加载草稿
    loadDraft() {
      try {
        const draft = uni.getStorageSync('draft_class_form');
        const step = uni.getStorageSync('draft_step');
        
        if (draft) {
          this.form = JSON.parse(draft);
          console.log('已加载草稿数据');
        }
        
        if (step !== null && step !== undefined && !isNaN(step)) {
          this.currentStep = parseInt(step);
          console.log('已恢复步骤:', this.currentStep);
        }
      } catch (e) {
        console.log('加载草稿失败:', e);
      }
    },
    
    // 提交拼班
    submitGroupClass() {
      console.log('开始提交拼班...');
      
      // 完整表单验证
      if (!this.validateForm()) {
        // 显示第一个错误信息
        const firstError = Object.values(this.errors)[0];
        if (firstError) {
          uni.showToast({
            title: firstError,
            icon: 'none',
            duration: 2000
          });
        }
        return;
      }
      
      // 验证精品班最低成班人数不能大于普通班最低成班人数
      const boutiqueMinUsers = parseInt(this.form.boutiqueMinUsers || 1);
      const minParticipants = parseInt(this.form.minParticipants || 0);
      
      if (boutiqueMinUsers > minParticipants) {
        uni.showToast({
          title: '精品班最低成班人数不能大于普通班最低成班人数',
          icon: 'none',
          duration: 3000
        });
        return;
      }
      
      // 验证上课前成班截止时间必须大于精品班成班截止时间
      const calculateTotalHours = (days, hours) => {
        const daysValue = parseInt(days || 0);
        const hoursValue = parseInt(hours || 0);
        return daysValue * 24 + hoursValue;
      };
      
      const normalTotalHours = calculateTotalHours(this.form.before_class_days, this.form.before_class_hours);
      const vipTotalHours = calculateTotalHours(this.form.boutique_before_class_days, this.form.boutique_before_class_hours);
      
      // 如果两个时间都设置了，才进行比较
      if (normalTotalHours > 0 && vipTotalHours > 0 && normalTotalHours <= vipTotalHours) {
        uni.showToast({
          title: '普通班截止时间必须大于精品班截止时间',
          icon: 'none',
          duration: 3000
        });
        return;
      }

      // 确保location对象格式正确
      const location = {
        name: this.form.locationName || this.form.location.name || '',
        address: this.form.location.address || this.form.locationName || '',
        province: this.form.location.province || '',
        city: this.form.location.city || '',
        district: this.form.location.district || '',
        longitude: this.form.location.longitude || '',
        latitude: this.form.location.latitude || '',
      };

      // 计算总课时数（小时）
      const hours = parseFloat(this.form.duration_hours) || 0;
      const minutes = parseFloat(this.form.duration_minutes) || 0;
      const totalDurationHours = hours + (minutes / 60);
      
      // 构建提交数据
      const submitData = {
        classType: this.form.classType,
        className: this.form.className,
        courseCategoryId: this.form.courseCategoryId,
        courseId: this.form.courseId,
        courseName: this.form.courseName,
        startTime: this.form.startTime,
        duration_hours: this.form.duration_hours || 0,
        duration_minutes: this.form.duration_minutes || 0,
        totalDurationHours: Number(totalDurationHours.toFixed(2)), // 总课时数，精确到2位小数
        enrollmentDeadline: this.form.enrollmentDeadline,
        // 将天数和小时转换为总小时数存储
        before_class_hours: calculateTotalHours(this.form.before_class_days, this.form.before_class_hours),
        before_class_minutes: this.form.before_class_minutes || 0,
        boutique_before_class_hours: calculateTotalHours(this.form.boutique_before_class_days, this.form.boutique_before_class_hours),
        boutique_before_class_minutes: this.form.boutique_before_class_minutes || 0,
        boutiqueMinUsers: this.form.boutiqueMinUsers || 1,
        location: location,
        locationName: this.form.locationName,
        minParticipants: this.form.minParticipants,
        maxParticipants: this.form.maxParticipants,
        // 班级级别配置（对应tx_group_class表）
        virtualEnabled: this.form.virtualEnabled,
        couponEnabled: this.form.couponEnabled,
        newUserPriceEnabled: this.form.newUserPriceEnabled,
        autoDeductionEnabled: this.form.autoDeductionEnabled,
        // 课程排期配置（会冗余到每个schedule）
        newbiePriceEnabled: this.form.newbiePriceEnabled,
        benefitPriceEnabled: this.form.benefitPriceEnabled,
        newProductPriceEnabled: this.form.newProductPriceEnabled,
        // 兼容字段（保持向下兼容）
        virtualParticipants: this.form.virtualEnabled, // 同步到新字段
        newPriceEnabled: this.form.newUserPriceEnabled, // 同步到新字段
        isFree: this.form.isFree,
        freeStudentId: this.form.freeStudentId,
        status: 0, // 添加状态字段，0=待匹配
        // 周期班特有字段
        ...(this.form.classType === '3' || this.form.classType === '4'
          ? {
              weekdays: this.form.weekdays,
              totalCycles: this.form.totalCycles,
            }
          : {}),
      };

      console.log('提交的数据:', submitData);
      console.log('普通班截止时间（总小时）:', submitData.before_class_hours);
      console.log('精品班截止时间（总小时）:', submitData.boutique_before_class_hours);

      uni.showLoading({
        title: '创建中...'
      });

      // 发送请求
      createGroupClass(submitData)
        .then(res => {
          uni.hideLoading();
          console.log('创建拼班成功:', res);
          console.log('API完整返回数据:', JSON.stringify(res));
          
          // 正确获取返回数据，考虑可能的嵌套结构
          let responseData = res;
          if (res.data && typeof res.data === 'object') {
            responseData = res.data;
          }
          
          this.createdClassId = responseData.class_id || null;
          this.scheduleId = responseData.schedule_id || null;
          // 设置课程次数信息
          this.totalCourses = responseData.total_courses || responseData.schedules_created || 0;
          this.isSingleCourse = responseData.is_single_course || (this.totalCourses === 1);
          
          console.log('获取到班级ID:', this.createdClassId);
          console.log('获取到排课ID:', this.scheduleId);
          console.log('总课程次数:', this.totalCourses);
          console.log('是否单课程:', this.isSingleCourse);
          
          // 显示成功弹窗
          this.showSuccessPopup = true;
          
          // 清除草稿
          try {
            uni.removeStorageSync('draft_class_form');
            uni.removeStorageSync('draft_step');
          } catch (e) {
            console.log('清除草稿失败:', e);
          }
        })
        .catch(err => {
          uni.hideLoading();
          console.error('创建拼班失败:', err);
          uni.showToast({
            title: '创建失败，请重试',
            icon: 'none',
            duration: 2000
          });
        });
    },

    // 计算总分钟数（用于比较截止时间）
    calculateTotalMinutes(hours, minutes) {
      const hoursValue = parseInt(hours || 0);
      const minutesValue = parseInt(minutes || 0);
      return hoursValue * 60 + minutesValue;
    },
    
    // 获取课程分类列表
    async fetchCourseCategories() {
      try {
        console.log('开始请求课程分类数据');
        const categories = await getCourseCategories();
        console.log('API返回的课程分类数据:', categories);

        if (categories && Array.isArray(categories)) {
          this.courseCategories = categories.map(item => ({
            label: item.name,
            value: item.id,
            ...item,
          }));
          console.log('格式化后的课程分类:', this.courseCategories);
        } else {
          console.error('课程分类数据格式不正确');
          uni.showToast({
            title: '获取课程分类失败',
            icon: 'none',
          });
        }
      } catch (error) {
        console.error('获取课程分类失败:', error);
        uni.showToast({
          title: '网络错误，请重试',
          icon: 'none',
        });
      }
    },
    
    // 获取班级类型列表
    async fetchClassTypes() {
      try {
        console.log('开始请求班级类型数据');
        const result = await getClassTypes();
        console.log('API返回的班级类型数据:', result);

        if (result && Array.isArray(result.data)) {
          this.classList = result.data;
          // 如果当前表单没有设置班级类型，则设置为第一个类型
          if (!this.form.classType && this.classList.length > 0) {
            this.form.classType = this.classList[0].value;
            this.form.className = this.classList[0].label;
          }
          console.log('设置班级类型:', this.form.classType, this.form.className);
        } else {
          console.log('使用默认班级类型');
          // 使用默认的班级类型列表
          this.classList = [
            { value: '3', label: '周期班' },
            { value: '4', label: '定制班' }
          ];
          if (!this.form.classType) {
            this.form.classType = '3';
            this.form.className = '周期班';
          }
        }
      } catch (error) {
        console.error('获取班级类型失败:', error);
        // 使用默认的班级类型列表
        this.classList = [
          { value: '3', label: '周期班' },
          { value: '4', label: '定制班' }
        ];
        if (!this.form.classType) {
          this.form.classType = '3';
          this.form.className = '周期班';
        }
      }
    },
    
    // 获取截止时间配置
    fetchDeadlineConfig() {
      // 统一使用ModuleConfig系统，不再区分开发模式
      getClassDeadlineConfig().then(res => {
        this.deadlineConfig = res.data || this.deadlineConfig;
        console.log('获取ModuleConfig配置成功:', this.deadlineConfig);
      }).catch(err => {
        console.log('获取ModuleConfig配置失败，使用默认配置:', err);
        // 使用默认配置作为降级方案
        this.deadlineConfig = {
          min_before_class_hours: 3,
          min_boutique_before_class_hours: 2,
          min_student_count_vip: 1
        };
      });
    },
    
    /**
     * 获取拼班业务配置
     * 
     * 这是一个使用通用配置系统的完整示例，展示了：
     * 1. 如何使用ModuleConfigLogic的通用方法
     * 2. 支持多级配置（platform/city/region）
     * 3. 类型转换和默认值处理
     * 4. 统一的配置获取接口
     * 
     * 配置系统架构说明：
     * 1. Config系统：处理系统级配置（logo、名称、版权等）
     *    - 接口：/businessapi/config/getConfig
     *    - 用于：App.vue中的全局配置加载
     * 
     * 2. ModuleConfig系统：处理业务模块配置（时长限制、价格模板等）
     *    - 接口：/businessapi/group_class/getBusinessConfig
     *    - 用于：具体业务页面的配置加载
     *    - 支持：平台级、城市级、区域级配置
     */
    async fetchBusinessConfig() {
      try {
        console.log('=== 开始获取拼班业务配置（通用配置系统示例） ===');
        
        // 使用通用配置方法获取完整的拼班配置
        // 这里演示了如何使用通用配置系统：
        // 1. 支持多级配置（platform/city/region）
        // 2. 支持类型转换和默认值
        // 3. 统一的配置获取接口
        const configParams = {
          config_level: 'platform', // 可以是 platform/city/region
          target_id: null // 如果是city或region级别，需要传入对应的ID
        };
        
        const response = await getGroupClassBusinessConfig(configParams);
        console.log('拼班业务配置响应:', response);
        
        if (response.code === 1 && response.data) {
          const config = response.data;
          
          // 更新截止时间配置
          if (config.deadline_config) {
            this.deadlineConfig = config.deadline_config;
            console.log('已更新截止时间配置:', this.deadlineConfig);
            
            // 同步更新表单中的默认值
            this.form.before_class_hours = String(config.deadline_config.min_before_class_hours);
            this.form.boutique_before_class_hours = String(config.deadline_config.min_boutique_before_class_hours);
            this.form.boutiqueMinUsers = String(config.deadline_config.min_student_count_vip);
          }
          
          // 更新人数配置
          if (config.participant_config) {
            this.form.minParticipants = String(config.participant_config.min_student_count);
            this.form.maxParticipants = String(config.participant_config.max_student_count);
            console.log('已更新人数配置:', config.participant_config);
          }
          
          // 更新业务配置
          if (config.business_config) {
            console.log('业务配置:', config.business_config);
            // 这里可以根据需要使用分润比例、提醒时间等配置
            if (config.business_config.commission_rate) {
              console.log('分润比例配置:', config.business_config.commission_rate);
            }
            if (config.business_config.remind_time) {
              console.log('提醒时间配置:', config.business_config.remind_time, '分钟');
            }
          }
          
          // 更新高级配置开关（根据配置设置合理的默认值）
          if (config.advanced_config) {
            console.log('高级配置开关:', config.advanced_config);
            
            // 班级级别配置（对应tx_group_class表）
            if (config.advanced_config.virtual_enabled !== undefined) {
              this.form.virtualEnabled = config.advanced_config.virtual_enabled;
            }
            if (config.advanced_config.coupon_enabled !== undefined) {
              this.form.couponEnabled = config.advanced_config.coupon_enabled;
            }
            if (config.advanced_config.new_user_price_enabled !== undefined) {
              this.form.newUserPriceEnabled = config.advanced_config.new_user_price_enabled;
            }
            
            if (config.advanced_config.auto_deduction_enabled !== undefined) {
              this.form.autoDeductionEnabled = config.advanced_config.auto_deduction_enabled;
            }
            
            // 课程排期配置（对应tx_course_schedule表）
            if (config.advanced_config.newbie_price_enabled !== undefined) {
              this.form.newbiePriceEnabled = config.advanced_config.newbie_price_enabled;
            }
            if (config.advanced_config.benefit_price_enabled !== undefined) {
              this.form.benefitPriceEnabled = config.advanced_config.benefit_price_enabled;
            }
            if (config.advanced_config.new_product_price_enabled !== undefined) {
              this.form.newProductPriceEnabled = config.advanced_config.new_product_price_enabled;
            }
            
            console.log('已更新高级配置开关');
          } else {
            // 如果没有配置数据，设置合理的默认值
            console.log('使用默认高级配置开关');
            this.setDefaultAdvancedConfig();
          }
          
          console.log('配置级别:', config.config_level);
          console.log('目标ID:', config.target_id);
          console.log('最后更新时间:', new Date(config.last_updated * 1000));
          
          // 显示配置加载成功提示
          if (this.isDevelopmentMode) {
            uni.showToast({
              title: '配置加载成功',
              icon: 'success',
              duration: 1500
            });
          }
          
        } else {
          console.warn('获取拼班配置失败，使用默认配置');
          this.useDefaultConfig();
        }
        
        console.log('=== 拼班业务配置获取完成 ===');
      } catch (error) {
        console.error('获取拼班配置失败:', error);
        this.useDefaultConfig();
        
        uni.showToast({
          title: '配置加载失败，使用默认设置',
          icon: 'none',
          duration: 2000
        });
      }
    },
    
    /**
     * 使用默认配置
     */
    useDefaultConfig() {
      console.log('使用默认配置');
      
      // 使用默认配置
      this.deadlineConfig = {
        min_before_class_hours: 3,
        min_boutique_before_class_hours: 2,
        min_student_count_vip: 1
      };
      
      // 使用默认调度配置
      this.scheduleConfig = {
        validation: {
          enabled: true,
          show_warning_modal: true,
          allow_next_week_start: true
        },
        interval: {
          min_hours: 2
        },
        advance: {
          max_advance_days: 90,
          min_advance_hours: 24,
          allow_same_day: false
        },
        skip_expired: {
          enabled: true
        }
      };
      
      // 同步更新表单默认值
      this.form.before_class_hours = '3';
      this.form.boutique_before_class_hours = '2';
      this.form.boutiqueMinUsers = '1';
      this.form.minParticipants = '3';
      this.form.maxParticipants = '20';
      
      // 设置默认高级配置开关
      this.setDefaultAdvancedConfig();
    },
    
    /**
     * 设置默认高级配置开关
     * 根据业务需求设置合理的默认值
     */
    setDefaultAdvancedConfig() {
      console.log('设置默认高级配置开关');
      
      // 班级级别配置（对应tx_group_class表）
      // 根据实际业务需求，这些开关通常应该启用
      this.form.virtualEnabled = true;         // 启用虚拟人数（提升课程吸引力）
      this.form.couponEnabled = true;          // 启用优惠券（促进报名）
      this.form.newUserPriceEnabled = true;    // 启用新人价（获客策略）
      this.form.autoDeductionEnabled = false;  // 自动代扣默认关闭（用户自主选择）
      
      // 课程排期配置（对应tx_course_schedule表）
      this.form.newbiePriceEnabled = true;     // 启用新人价（与班级级别保持一致）
      this.form.benefitPriceEnabled = true;    // 启用权益价（会员策略）
      this.form.newProductPriceEnabled = false; // 新品价默认关闭（按需开启）
      
      // 同步到兼容字段
      this.form.virtualParticipants = this.form.virtualEnabled;
      this.form.newPriceEnabled = this.form.newUserPriceEnabled;
      
      console.log('默认高级配置开关设置完成', {
        virtualEnabled: this.form.virtualEnabled,
        couponEnabled: this.form.couponEnabled,
        newUserPriceEnabled: this.form.newUserPriceEnabled,
        autoDeductionEnabled: this.form.autoDeductionEnabled,
        newbiePriceEnabled: this.form.newbiePriceEnabled,
        benefitPriceEnabled: this.form.benefitPriceEnabled,
        newProductPriceEnabled: this.form.newProductPriceEnabled
      });
    },

    /**
     * 获取调度配置
     */
    async fetchScheduleConfig() {
      try {
        console.log('=== 开始获取调度配置 ===');
        
        const configParams = {
          config_level: 'platform',
          target_id: null
        };
        
        const response = await this.$http.request({
          url: '/businessapi/group_class/getScheduleConfig',
          method: 'GET',
          data: configParams
        });
        
        console.log('调度配置响应:', response);
        
        if (response.code === 1 && response.data) {
          this.scheduleConfig = response.data;
          console.log('已更新调度配置:', this.scheduleConfig);
        } else {
          console.warn('获取调度配置失败，使用默认配置');
          this.scheduleConfig = {
            validation: {
              enabled: true,
              show_warning_modal: true,
              allow_next_week_start: true
            },
            interval: {
              min_hours: 2
            },
            advance: {
              max_advance_days: 90,
              min_advance_hours: 24,
              allow_same_day: false
            },
            skip_expired: {
              enabled: true
            }
          };
        }
        
        console.log('=== 调度配置获取完成 ===');
      } catch (error) {
        console.error('获取调度配置失败:', error);
        
        // 使用默认配置
        this.scheduleConfig = {
          validation: {
            enabled: true,
            show_warning_modal: true,
            allow_next_week_start: true
          },
          interval: {
            min_hours: 2
          },
          advance: {
            max_advance_days: 90,
            min_advance_hours: 24,
            allow_same_day: false
          },
          skip_expired: {
            enabled: true
          }
        };
      }
    },
    
    // 成功弹窗操作
    goToInviteTeacher() {
      this.showSuccessPopup = false;
      
      // 检查是否有拼班ID
      if (!this.createdClassId) {
        uni.showToast({
          title: '拼班ID不存在，无法继续操作',
          icon: 'none',
          duration: 2000
        });
        console.error('createdClassId为空，无法跳转');
        return;
      }
      
      // 根据课程次数决定跳转页面
      console.log('当前拼班信息:', {
        classId: this.createdClassId,
        scheduleId: this.scheduleId,
        totalCourses: this.totalCourses,
        isSingleCourse: this.isSingleCourse
      });
      
      if (this.isSingleCourse) {
        // 单课程：跳转邀请陪伴师页面
        if (!this.scheduleId) {
          uni.showToast({
            title: '排课ID不存在，无法邀请陪伴师',
            icon: 'none',
            duration: 2000
          });
          console.error('scheduleId为空，无法跳转到邀请陪伴师页面');
          return;
        }
        
        console.log('单课程，跳转到邀请陪伴师页面，排课ID:', this.scheduleId);
        uni.navigateTo({
          url: `/pages/teacher_manage/index?id=${this.scheduleId}`
        });
      } else {
        // 多课程：跳转排课列表页
        console.log('多课程，跳转到排课页面，拼班ID:', this.createdClassId);
        uni.navigateTo({
          url: `/pages/class_manage/index?classId=${this.createdClassId}`
        });
      }
    },
    
    goToHomePage() {
      this.showSuccessPopup = false;
      uni.switchTab({
        url: '/pages/index/index'
      });
    },
    
    // 通用的完整重置方法
    resetAllData() {
      console.log('开始执行完整重置...');
      
      // 完整重置表单数据
      this.form = {
        classType: '3', // 默认选择周期班
        className: '周期班',
        courseCategoryId: '',
        courseCategoryName: '',
        courseName: '',
        courseId: '',
        coachId: '',
        startTime: '',
        duration: '',
        duration_hours: '', // 默认为空
        duration_minutes: '', // 默认为空
        enrollmentDeadline: '',
        before_class_hours: '3', // 默认3小时
        before_class_minutes: '0', // 默认0分钟
        before_class_days: '', // 普通班天数（新增）
        boutique_before_class_hours: '2', // 默认2小时
        boutique_before_class_minutes: '0', // 默认0分钟
        boutique_before_class_days: '', // 精品班天数（新增）
        beforeClassTime: '3', // 普通班快速选择值
        boutiqueBeforeClassTime: '2', // 精品班快速选择值
        boutiqueMinUsers: '1', // 精品班最低成班人数
        locationName: '',
        location: {
          name: '',
          province: '',
          city: '',
          district: '',
          address: '',
          longitude: '',
          latitude: '',
        },
        weekdays: [],
        weekDayName: '',
        totalCycles: '',
        minParticipants: '3',
        maxParticipants: '20',
        // 高级配置开关（对应tx_group_class表）
        virtualEnabled: true, // 是否启用虚拟人数（默认启用）
        couponEnabled: true, // 是否启用优惠券（默认启用）  
        newUserPriceEnabled: true, // 是否启用新人价（默认启用）
        autoDeductionEnabled: false, // 是否允许自动代扣（默认关闭）
        // 课程排期配置（对应tx_course_schedule表）
        newbiePriceEnabled: true, // 是否启用新人价（排课级别，默认启用）
        benefitPriceEnabled: true, // 是否启用权益价（默认启用）
        newProductPriceEnabled: false, // 是否启用新品价（默认关闭）
        // 兼容老字段
        virtualParticipants: false, // 启用虚拟人数（已废弃，使用virtualEnabled）
        newPriceEnabled: false, // 启用新人价（已废弃，使用newUserPriceEnabled）
        isFree: false, // 免单学员
        freeStudentId: '', // 免单学员ID
        freeStudentName: '',
        paymentType: '', // 支付类型
        status: 0, // 状态
        minIncome: '',
        maxIncome: '',
      };
      
      // 重置步骤相关状态
      this.currentStep = 0;
      
      // 重置选择器状态
      this.showCalendar = false;
      this.showCategorySelect = false;
      this.showCourseSelect = false;
      this.showMap = false;
      this.calendarType = '';
      
      // 重置其他状态变量
      this.selectedWeekdays = [false, false, false, false, false, false, false];
      this.selectedDuration = ''; // 默认不选择任何预设时长
      this.showHoursDuration = false; // 默认不显示小时输入框
      this.showDaysDuration = false;
      this.showBeforeClassHours = true;
      this.showBoutiqueBeforeClassHours = true;
      
      // 重置成功弹窗相关数据
      this.createdClassId = null;
      this.scheduleId = null;
      // 重置课程次数信息
      this.totalCourses = 0;
      this.isSingleCourse = false;
      
      // 清除草稿数据
      try {
        uni.removeStorageSync('draft_class_form');
        uni.removeStorageSync('draft_step');
        console.log('已清除草稿数据');
      } catch (e) {
        console.log('清除草稿数据失败:', e);
      }
      
      // 清除缓存数据
      try {
        Cache.set('initiateForm', '');
        Cache.set('STUDENTID', '');
        console.log('已清除缓存数据');
      } catch (e) {
        console.log('清除缓存数据失败:', e);
      }
      
      console.log('完整重置已完成');
      
      // 重新初始化页面状态
      this.initializePageState();
      
      // 重新设置默认高级配置开关
      this.setDefaultAdvancedConfig();
    },

    continueCreateClass() {
      this.showSuccessPopup = false;
      
      // 调用通用重置方法
      this.resetAllData();
      
      console.log('表单已完全重置，准备创建新的拼班');
      
      uni.showToast({
        title: '已重置，可以创建新拼班',
        icon: 'success',
        duration: 1500
      });
    },
    
    // 选择课程分类
    selectCategoryConfirm(e) {
      console.log('选择的课程分类:', e);
      const category = e[0];

      // 同时保存ID和名称
      this.form.courseCategoryId = category.value;
      this.form.courseCategoryName = category.label;

      // 重置课程相关字段
      this.form.courseId = '';
      this.form.courseName = '';

      this.showCategorySelect = false;

      // 使用ID获取该分类下的课程列表
      this.fetchCoursesByCategory(category.value);
    },

    // 获取分类下的课程列表
    async fetchCoursesByCategory(categoryId) {
      console.log('使用分类ID获取课程:', categoryId);
      try {
        const courses = await getCoursesByCategory({ category_id: categoryId });
        console.log('课程列表API返回:', courses);

        if (courses && Array.isArray(courses)) {
          this.courseList = courses.map(course => ({
            label: course.title,
            value: course.id,
            ...course,
          }));
          console.log('格式化后的课程列表:', this.courseList);
        } else {
          console.log('该分类下没有课程或数据格式不正确');
          this.courseList = [];
          uni.showToast({
            title: '该分类下暂无课程',
            icon: 'none',
          });
        }
      } catch (error) {
        console.error('获取课程列表失败:', error);
        uni.showToast({
          title: '获取课程列表失败',
          icon: 'none',
        });
      }
    },

    // 检查并显示课程选择
    checkAndShowCourseSelect() {
      if (!this.form.courseCategoryId) {
        uni.showToast({
          title: '请先选择课程分类',
          icon: 'none',
        });
        return;
      }

      if (this.courseList.length === 0) {
        uni.showToast({
          title: '该分类下暂无课程',
          icon: 'none',
        });
        return;
      }

      this.showCourseSelect = true;
    },

    // 选择课程
    selectCourseConfirm(e) {
      console.log('选择的课程:', e);
      const course = e[0];
      this.form.courseName = course.label;
      this.form.courseId = course.value;
      this.showCourseSelect = false;
    },
    
    chooseMap() {
      console.log('选择地图位置');
      // #ifdef APP-PLUS
      uni.navigateTo({
        url: `/components/web-view/web-view?url=${encodeURIComponent(this.mapUrl)}`
      });
      // #endif
      // #ifdef H5
      this.showMap = true
      // #endif
    },
    
    openMap() {
      this.$refs.mapSelector.open();
    },
    
    handlerSelectMap(data) {
      console.log('选择的位置详细数据:', JSON.stringify(data));
      
      // 如果data是一个包含location对象的对象，则使用它
      let locationData = data;
      
      // 处理可能的嵌套数据结构（如来自postMessage的数据）
      if (data.data && data.data.type === 'locationSelected' && data.data.location) {
        locationData = data.data.location;
        console.log('从postMessage中提取location数据:', locationData);
      } else if (data.location && typeof data.location === 'object') {
        // 数据已经是正确格式，直接使用
        console.log('直接使用data中的location数据');
      }
      
      // 确保address是字符串
      let addressStr = '';
      if (typeof locationData.address === 'string') {
        addressStr = locationData.address;
      } else if (typeof locationData.address === 'object' && locationData.address) {
        addressStr = locationData.address.name || '';
      }
      
      // 提取location对象中的经纬度
      let longitude = '';
      let latitude = '';
      
      // 1. 尝试从location对象中提取
      if (locationData.location && typeof locationData.location === 'object') {
        if (locationData.location.lng && locationData.location.lat) {
          // 直接在location对象中
          longitude = locationData.location.lng;
          latitude = locationData.location.lat;
          console.log('从location对象提取经纬度:', {lng: longitude, lat: latitude});
        }
      }
      
      // 2. 尝试从根对象中提取
      if (!longitude && !latitude && locationData.lng && locationData.lat) {
        longitude = locationData.lng;
        latitude = locationData.lat;
        console.log('从根对象提取经纬度:', {lng: longitude, lat: latitude});
      }
      
      // 3. 尝试从嵌套的position.point对象提取
      if (!longitude && !latitude && 
          locationData.position && 
          locationData.position.point && 
          locationData.position.point.longitude && 
          locationData.position.point.latitude) {
        longitude = locationData.position.point.longitude;
        latitude = locationData.position.point.latitude;
        console.log('从position.point对象提取经纬度:', {lng: longitude, lat: latitude});
      }
      
      // 4. 尝试从location.position.point对象提取
      if (!longitude && !latitude && 
          locationData.location && 
          locationData.location.position && 
          locationData.location.position.point) {
        longitude = locationData.location.position.point.longitude;
        latitude = locationData.location.position.point.latitude;
        console.log('从location.position.point对象提取经纬度:', {lng: longitude, lat: latitude});
      }
      
      console.log('最终获取的经纬度:', {longitude, latitude});
      
      // 设置表单中的位置信息
      this.form.locationName = addressStr || locationData.name || '';
      this.form.location = {
        name: locationData.name || addressStr || '',
        address: addressStr || '',
        province: locationData.province || '',
        city: locationData.city || '',
        district: locationData.district || '',
        longitude: longitude || '',
        latitude: latitude || ''
      };
      
      console.log('设置后的位置信息:', JSON.stringify(this.form.location));
      this.showMap = false;
      
      // 清除地点相关的错误信息
      this.clearError('locationName');
      
      uni.showToast({
        title: '地点已选择',
        icon: 'success',
        duration: 1500
      });
    },
    
    updateWeekdays(index, val) {
      console.log('更新星期选择:', this.weekList[index].text, val ? '选中' : '取消');
      console.log('更新前selectedWeekdays:', JSON.stringify(this.selectedWeekdays));
      console.log('更新前form.weekdays:', JSON.stringify(this.form.weekdays));
      
      // 更新选中状态数组
      this.$set(this.selectedWeekdays, index, val);
      
      // 使用$nextTick确保DOM更新完成后再计算
      this.$nextTick(() => {
        // 重新计算选中的星期
        const weekdays = [];
        const weekdayNames = [];

        this.selectedWeekdays.forEach((selected, idx) => {
          if (selected) {
            weekdays.push(this.weekList[idx].value);
            weekdayNames.push(this.weekList[idx].text);
          }
        });

        // 强制更新表单数据，确保响应式更新
        this.$set(this.form, 'weekdays', weekdays);
        this.$set(this.form, 'weekDayName', weekdayNames.join(', '));
        
        console.log('更新后selectedWeekdays:', JSON.stringify(this.selectedWeekdays));
        console.log('更新后form.weekdays:', JSON.stringify(this.form.weekdays));
        console.log('已选择星期:', this.form.weekDayName || '无');
        console.log('星期数组长度:', weekdays.length);
        
        // 数据一致性检查
        const selectedCount = this.selectedWeekdays.filter(Boolean).length;
        if (weekdays.length !== selectedCount) {
          console.warn('数据不一致！weekdays长度:', weekdays.length, 'selectedWeekdays选中数量:', selectedCount);
        } else {
          console.log('数据同步正常');
        }
        
        // 只有在选择了至少一个星期时才清除错误信息
        if (weekdays.length > 0) {
          this.clearError('weekdays');
          console.log('已选择星期，清除错误信息');
        } else {
          console.log('未选择任何星期，保留可能的错误信息');
          // 如果没有选择任何星期，立即触发验证以显示错误
          if (this.form.classType == 3 || this.form.classType == 4) {
            this.errors.weekdays = '请选择上课星期';
            console.log('设置星期错误信息:', this.errors.weekdays);
          }
        }
      });
    },
    
    // 快速选择开始时间
    selectQuickStartTime(option) {
      console.log('快速选择时间:', option);
      
      if (option.value === 'custom') {
        // 选择自定义时间，如果没有时间数据则设置默认时间
        if (!this.form.startTime) {
          // 如果没有时间数据，设置默认时间（当前时间+1小时，整点）
          const now = new Date();
          now.setHours(now.getHours() + 1);
          now.setMinutes(0);
          now.setSeconds(0);
          
          const year = now.getFullYear();
          const month = String(now.getMonth() + 1).padStart(2, '0');
          const day = String(now.getDate()).padStart(2, '0');
          const hours = String(now.getHours()).padStart(2, '0');
          const minutes = String(now.getMinutes()).padStart(2, '0');
          
          this.form.startTime = `${year}-${month}-${day} ${hours}:${minutes}:00`;
          console.log('设置默认时间:', this.form.startTime);
        } else {
          console.log('保持当前时间:', this.form.startTime);
        }
        
        // 打开时间选择器，显示当前设置的时间
        this.openCalendar('start');
        return;
      }
      
      const now = new Date();
      let selectedTime = '';
      
      switch(option.value) {
        case 'today_afternoon':
          selectedTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} 14:00:00`;
          break;
        case 'today_evening':
          selectedTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} 19:00:00`;
          break;
        case 'tomorrow_morning':
          const tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000);
          selectedTime = `${tomorrow.getFullYear()}-${String(tomorrow.getMonth() + 1).padStart(2, '0')}-${String(tomorrow.getDate()).padStart(2, '0')} 09:00:00`;
          break;
        case 'tomorrow_afternoon':
          const tomorrow2 = new Date(now.getTime() + 24 * 60 * 60 * 1000);
          selectedTime = `${tomorrow2.getFullYear()}-${String(tomorrow2.getMonth() + 1).padStart(2, '0')}-${String(tomorrow2.getDate()).padStart(2, '0')} 14:00:00`;
          break;
        case 'weekend':
          // 计算本周六
          const daysUntilSaturday = (6 - now.getDay()) % 7 || 7;
          const saturday = new Date(now.getTime() + daysUntilSaturday * 24 * 60 * 60 * 1000);
          selectedTime = `${saturday.getFullYear()}-${String(saturday.getMonth() + 1).padStart(2, '0')}-${String(saturday.getDate()).padStart(2, '0')} 10:00:00`;
          break;
      }
      
      this.form.startTime = selectedTime;
      
      // 清除时间相关错误
      this.clearError('startTime');
      
      console.log('快速选择的时间:', selectedTime);
      
      uni.showToast({
        title: `已选择${option.label}`,
        icon: 'success',
        duration: 1500
      });
    },
    
    // 测试设置时间
    testSetTime() {
      const now = new Date();
      const testTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} 14:30:00`;
      this.form.startTime = testTime;
      console.log('测试设置时间:', testTime);
      console.log('displayStartTime:', this.displayStartTime);
      
      uni.showToast({
        title: '测试时间已设置',
        icon: 'success',
        duration: 1500
      });
    },
    
    // 测试选择器回调
    testPickerCallback() {
      console.log('=== 测试u-picker回调 ===');
      
      // 模拟u-picker回调的参数格式（timestamp格式）
      const targetDate = new Date('2025-05-23 14:30:00');
      const mockData = {
        timestamp: Math.floor(targetDate.getTime() / 1000), // u-picker使用秒级时间戳
        year: targetDate.getFullYear(),
        month: targetDate.getMonth() + 1,
        day: targetDate.getDate(),
        hour: targetDate.getHours(),
        minute: targetDate.getMinutes()
      };
      
      console.log('模拟u-picker数据:', mockData);
      
      // 设置calendarType
      this.calendarType = 'start';
      
      // 调用calendarConfirm
      this.calendarConfirm(mockData);
    },
    
    // 新增calendarConfirm方法，参考index.vue的实现
    calendarConfirm(e) {
      console.log('日历选择返回数据:', e);

      try {
        let timestamp;
        if (e.timestamp) {
          timestamp = e.timestamp;
        } else if (e.value) {
          timestamp = new Date(e.value).getTime();
        } else if (typeof e === 'number') {
          timestamp = e;
        } else if (e.year && e.month && e.day) {
          // 处理年月日格式
          timestamp = new Date(e.year, e.month - 1, e.day, e.hour || 0, e.minute || 0).getTime();
        } else {
          console.error('无法识别的日期格式:', e);
          return;
        }

        const date = new Date(timestamp);
        const year = date.getFullYear();
        const month = (date.getMonth() + 1).toString().padStart(2, '0');
        const day = date.getDate().toString().padStart(2, '0');
        const hours = date.getHours().toString().padStart(2, '0');
        const minutes = date.getMinutes().toString().padStart(2, '0');

        const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:00`;
        console.log('格式化后的日期时间:', formattedDate);

        if (this.calendarType === 'start') {
          this.form.startTime = formattedDate;
          
          // 清除时间相关错误
          this.clearError('startTime');
          
          uni.showToast({
            title: '上课时间已设置',
            icon: 'success',
            duration: 1500
          });
        } else if (this.calendarType === 'end') {
          this.form.enrollmentDeadline = formattedDate;
        }
      } catch (error) {
        console.error('日期转换错误:', error, e);
        uni.showToast({
          title: '日期格式错误，请重新选择',
          icon: 'none',
        });
      }
    },
    
    // 显示当前状态（调试用）
    showCurrentStatus() {
      console.log('=== 当前状态信息 ===');
      console.log('currentStep:', this.currentStep);
      console.log('form.startTime:', this.form.startTime);
      console.log('form.classType:', this.form.classType);
      console.log('form.locationName:', this.form.locationName);
      console.log('calendarType:', this.calendarType);
      console.log('showCalendar:', this.showCalendar);
      console.log('selectedDuration:', this.selectedDuration);
      console.log('selectedWeekdays:', this.selectedWeekdays);
      console.log('=== 状态信息结束 ===');
      
      uni.showToast({
        title: '状态信息已输出到控制台',
        icon: 'none',
        duration: 1500
      });
    },

    // 表单验证方法
    validateForm() {
      this.errors = {}; // 清空之前的错误
      let isValid = true;

      // 第一步验证：课程信息（基础信息）
      if (this.currentStep >= 0) {
        if (!this.form.courseCategoryId) {
          this.errors.courseCategoryName = '请选择课程分类';
          isValid = false;
        }
        
        if (!this.form.courseId) {
          this.errors.courseName = '请选择课程名称';
          isValid = false;
        }
        
        if (!this.form.startTime) {
          this.errors.startTime = '请选择上课时间';
          isValid = false;
        }
        
        // 时长验证：支持预设和自定义时长
        const hours = parseInt(this.form.duration_hours) || 0;
        const minutes = parseInt(this.form.duration_minutes) || 0;
        if (hours <= 0 && minutes <= 0) {
          this.errors.duration = '请选择或输入课程时长';
          isValid = false;
        } else if (hours === 0 && minutes < 15) {
          this.errors.duration = '课程时长不能少于15分钟';
          isValid = false;
        } else if (hours > 8) {
          this.errors.duration = '课程时长不能超过8小时';
          isValid = false;
        }
        
        if (!this.form.locationName) {
          this.errors.locationName = '请选择上课地点';
          isValid = false;
        }
      }

      // 第二步验证：班级信息（包含班级类型和周期班设置）
      if (this.currentStep >= 1) {
        if (!this.form.classType) {
          this.errors.classType = '请选择班级类型';
          isValid = false;
        }
        
        // 周期班特殊验证
        if ((this.form.classType == 3 || this.form.classType == 4)) {
          if (!this.form.weekdays || this.form.weekdays.length === 0) {
            this.errors.weekdays = '请选择上课星期';
            isValid = false;
          }
          
          if (!this.form.totalCycles || this.form.totalCycles <= 0) {
            this.errors.totalCycles = '请输入总周期数';
            isValid = false;
          }
        }
      }

      // 第三步验证：成班设置
      if (this.currentStep >= 2) {
        if (!this.form.minParticipants || this.form.minParticipants <= 0) {
          this.errors.minParticipants = '请输入最小人数';
          isValid = false;
        }
        
        if (!this.form.maxParticipants || this.form.maxParticipants <= 0) {
          this.errors.maxParticipants = '请输入最大人数';
          isValid = false;
        }
        
        if (this.form.minParticipants && this.form.maxParticipants && 
            parseInt(this.form.minParticipants) >= parseInt(this.form.maxParticipants)) {
          this.errors.maxParticipants = '最大人数必须大于最小人数';
          isValid = false;
        }
        
        if (!this.form.boutiqueMinUsers || this.form.boutiqueMinUsers <= 0) {
          this.errors.boutiqueMinUsers = '请输入精品班最低人数';
          isValid = false;
        }
        
        // 验证精品班人数不能大于普通班最小人数
        if (this.form.boutiqueMinUsers && this.form.minParticipants &&
            parseInt(this.form.boutiqueMinUsers) > parseInt(this.form.minParticipants)) {
          this.errors.boutiqueMinUsers = '精品班最低人数不能大于普通班最小人数';
          isValid = false;
        }
      }

      // 第四步验证：高级设置（通常不需要验证）
      // 高级设置步骤通常是可选的，不需要强制验证

      return isValid;
    },

    // 验证当前步骤
    validateCurrentStep() {
      this.errors = {}; // 清空之前的错误
      let isValid = true;

      switch (this.currentStep) {
        case 0: // 课程信息（基础信息）
          if (!this.form.courseCategoryId) {
            this.errors.courseCategoryName = '请选择课程分类';
            isValid = false;
          }
          
          if (!this.form.courseId) {
            this.errors.courseName = '请选择课程名称';
            isValid = false;
          }
          
          if (!this.form.startTime) {
            this.errors.startTime = '请选择上课时间';
            isValid = false;
          }
          
          // 时长验证：支持预设和自定义时长
          const hours = parseInt(this.form.duration_hours) || 0;
          const minutes = parseInt(this.form.duration_minutes) || 0;
          if (hours <= 0 && minutes <= 0) {
            this.errors.duration = '请选择或输入课程时长';
            isValid = false;
          } else if (hours === 0 && minutes < 15) {
            this.errors.duration = '课程时长不能少于15分钟';
            isValid = false;
          } else if (hours > 8) {
            this.errors.duration = '课程时长不能超过8小时';
            isValid = false;
          }
          
          if (!this.form.locationName) {
            this.errors.locationName = '请选择上课地点';
            isValid = false;
          }
          break;

        case 1: // 班级信息（包含班级类型和周期班设置）
          if (!this.form.classType) {
            this.errors.classType = '请选择班级类型';
            isValid = false;
          }
          
          // 周期班特殊验证
          if ((this.form.classType == 3 || this.form.classType == 4)) {
            if (!this.form.weekdays || this.form.weekdays.length === 0) {
              this.errors.weekdays = '请选择上课星期';
              isValid = false;
            }
            
            if (!this.form.totalCycles || this.form.totalCycles <= 0) {
              this.errors.totalCycles = '请输入总周期数';
              isValid = false;
            }
          }
          break;

        case 2: // 成班设置
          if (!this.form.minParticipants || this.form.minParticipants <= 0) {
            this.errors.minParticipants = '请输入最小人数';
            isValid = false;
          }
          
          if (!this.form.maxParticipants || this.form.maxParticipants <= 0) {
            this.errors.maxParticipants = '请输入最大人数';
            isValid = false;
          }
          
          if (this.form.minParticipants && this.form.maxParticipants && 
              parseInt(this.form.minParticipants) >= parseInt(this.form.maxParticipants)) {
            this.errors.maxParticipants = '最大人数必须大于最小人数';
            isValid = false;
          }
          
          if (!this.form.boutiqueMinUsers || this.form.boutiqueMinUsers <= 0) {
            this.errors.boutiqueMinUsers = '请输入精品班最低人数';
            isValid = false;
          }
          
          // 验证精品班人数不能大于普通班最小人数
          if (this.form.boutiqueMinUsers && this.form.minParticipants &&
              parseInt(this.form.boutiqueMinUsers) > parseInt(this.form.minParticipants)) {
            this.errors.boutiqueMinUsers = '精品班最低人数不能大于普通班最小人数';
            isValid = false;
          }
          break;

        case 3: // 高级设置（可选，通常不需要验证）
          // 高级设置步骤通常是可选的，不需要强制验证
          break;
      }

      return isValid;
    },

    // 清除特定字段的错误
    clearError(field) {
      if (this.errors[field]) {
        delete this.errors[field];
      }
    },

    // 测试星期验证功能
    testWeekdayValidation() {
      console.log('=== 测试星期验证功能 ===');
      
      // 先检查数据同步状态
      this.checkDataSync();
      
      // 显示当前状态
      console.log('当前班级类型:', this.form.classType);
      console.log('当前选中星期:', this.form.weekdays);
      console.log('星期数组长度:', this.form.weekdays ? this.form.weekdays.length : 0);
      console.log('当前星期名称:', this.form.weekDayName);
      console.log('当前选中状态:', this.selectedWeekdays);
      console.log('当前错误信息:', this.errors);
      
      // 手动触发验证
      const isValid = this.validateCurrentStep();
      console.log('验证结果:', isValid);
      console.log('验证后错误信息:', this.errors);
      
      // 显示提示
      if (this.errors.weekdays) {
        uni.showToast({
          title: this.errors.weekdays,
          icon: 'none',
          duration: 2000
        });
        console.log('显示星期错误提示:', this.errors.weekdays);
      } else if (isValid) {
        uni.showToast({
          title: '星期验证通过',
          icon: 'success',
          duration: 2000
        });
      } else {
        const otherErrors = Object.keys(this.errors).filter(key => key !== 'weekdays');
        const errorMsg = otherErrors.length > 0 ? `其他验证失败: ${otherErrors.join(', ')}` : '验证失败';
        uni.showToast({
          title: errorMsg,
          icon: 'none',
          duration: 2000
        });
      }
      
      console.log('=== 星期验证测试完成 ===');
    },
    
    // 清空所有星期选择（测试用）
    clearAllWeekdays() {
      console.log('清空所有星期选择');
      this.selectedWeekdays = [false, false, false, false, false, false, false];
      this.form.weekdays = [];
      this.form.weekDayName = '';
      
      // 注意：这里不清除错误信息，让用户看到验证效果
      console.log('已清空所有星期，weekdays长度:', this.form.weekdays.length);
      
      uni.showToast({
        title: '所有星期已清空',
        icon: 'success',
        duration: 1500
      });
    },

    // 修复数据同步问题
    fixWeekdaySync() {
      console.log('=== 修复星期数据同步 ===');
      console.log('修复前selectedWeekdays:', JSON.stringify(this.selectedWeekdays));
      console.log('修复前form.weekdays:', JSON.stringify(this.form.weekdays));
      
      // 方案1：根据form.weekdays重建selectedWeekdays
      if (this.form.weekdays && this.form.weekdays.length > 0) {
        // 重置selectedWeekdays
        this.selectedWeekdays = [false, false, false, false, false, false, false];
        
        // 根据form.weekdays重新设置selectedWeekdays
        this.form.weekdays.forEach(weekdayValue => {
          const index = this.weekList.findIndex(item => item.value === weekdayValue);
          if (index !== -1) {
            this.selectedWeekdays[index] = true;
          }
        });
        
        console.log('修复后selectedWeekdays:', JSON.stringify(this.selectedWeekdays));
        
        uni.showToast({
          title: '数据同步已修复',
          icon: 'success',
          duration: 1500
        });
      } else {
        // 如果form.weekdays为空，确保selectedWeekdays也为空
        this.selectedWeekdays = [false, false, false, false, false, false, false];
        console.log('form.weekdays为空，已重置selectedWeekdays');
        
        uni.showToast({
          title: '数据已重置',
          icon: 'success',
          duration: 1500
        });
      }
      
      console.log('=== 数据同步修复完成 ===');
    },

    // 检查数据同步状态
    checkDataSync() {
      console.log('=== 检查数据同步状态 ===');
      
      // 检查星期数据同步
      const selectedCount = this.selectedWeekdays.filter(Boolean).length;
      const weekdaysCount = this.form.weekdays ? this.form.weekdays.length : 0;
      
      console.log('selectedWeekdays选中数量:', selectedCount);
      console.log('form.weekdays数量:', weekdaysCount);
      console.log('form.weekdays内容:', JSON.stringify(this.form.weekdays));
      console.log('selectedWeekdays状态:', JSON.stringify(this.selectedWeekdays));
      
      if (selectedCount !== weekdaysCount) {
        console.warn('发现数据不同步，自动修复...');
        this.fixWeekdaySync();
      } else {
        console.log('数据同步正常');
      }
      
      console.log('=== 数据同步检查完成 ===');
    },

    // 更新自定义时长
    updateCustomDuration() {
      console.log('更新自定义时长:', this.form.duration_hours, this.form.duration_minutes);
      
      const hours = parseInt(this.form.duration_hours) || 0;
      const minutes = parseInt(this.form.duration_minutes) || 0;
      
      if (hours > 0 || minutes > 0) {
        let durationText = '';
        if (hours > 0) {
          durationText += `${hours}小时`;
        }
        if (minutes > 0) {
          durationText += `${minutes}分钟`;
        }
        this.form.duration = durationText;
        
        // 清除时长相关错误
        this.clearError('duration');
        
        console.log('自定义时长已更新:', this.form.duration);
      } else {
        this.form.duration = '';
      }
    },

    // 切换小时显示
    toggleHoursDuration(e) {
      this.showHoursDuration = e;
      if (!e) {
        this.form.duration_hours = '';
      }
      // 更新时长显示
      this.updateCustomDuration();
    },

    // 格式化时长显示
    formatDurationDisplay() {
      const hours = parseInt(this.form.duration_hours) || 0;
      const minutes = parseInt(this.form.duration_minutes) || 0;
      
      let display = '';
      if (hours > 0) {
        display += `${hours}小时`;
      }
      if (minutes > 0) {
        display += `${minutes}分钟`;
      }
      
      return display || '0分钟';
    },

    // 智能检测当前时长设置
    detectDurationState() {
      const hours = parseInt(this.form.duration_hours) || 0;
      const minutes = parseInt(this.form.duration_minutes) || 0;
      
      // 如果没有设置任何时长，保持默认状态（不显示输入框）
      if (hours === 0 && minutes === 0) {
        this.selectedDuration = '';
        this.showHoursDuration = false;
        return;
      }
      
      // 计算总小时数，检查是否匹配预设选项
      const totalHours = hours + minutes / 60;
      
      for (const duration of this.quickDurations) {
        if (duration.value !== 'custom' && parseFloat(duration.value) === totalHours) {
          // 匹配预设选项，不显示输入框
          this.selectedDuration = duration.value;
          this.showHoursDuration = false;
          return;
        }
      }
      
      // 不匹配任何预设选项，但有数据，说明是自定义的
      // 只有在这种情况下才设为自定义并显示输入框
      this.selectedDuration = 'custom';
      this.showHoursDuration = hours > 0;
    },

    // 页面初始化
    initializePageState() {
      // 检测时长状态
      this.detectDurationState();
      
      console.log('页面状态初始化完成');
      console.log('当前时长类型:', this.selectedDuration);
      console.log('显示小时输入:', this.showHoursDuration);
      console.log('当前时间:', this.form.startTime);
      console.log('显示时间:', this.form.startTime);
    },
    
    // 测试设置当前时间
    testSetCurrentTime() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, '0');
      const day = String(now.getDate()).padStart(2, '0');
      const hours = String(now.getHours()).padStart(2, '0');
      const minutes = String(now.getMinutes()).padStart(2, '0');
      
      this.form.startTime = `${year}-${month}-${day} ${hours}:${minutes}:00`;
      
      console.log('测试设置时间:', this.form.startTime);
      
      uni.showToast({
        title: '时间已设置为当前时间',
        icon: 'success',
        duration: 1500
      });
    },
    
    // 测试打开时间选择器
    testOpenTimePicker() {
      console.log('=== 测试打开时间选择器 ===');
      console.log('当前form.startTime:', this.form.startTime);
      console.log('即将打开时间选择器...');
      
      // 先设置一个测试时间
      this.form.startTime = '2025-05-24 14:00:00';
      console.log('设置测试时间:', this.form.startTime);
      
      // 然后打开选择器
      this.openCalendar('start');
    },
    
    // 测试设置时长
    testSetDuration() {
      // 设置一个1.5小时的时长
      this.form.duration_hours = '1';
      this.form.duration_minutes = '30';
      this.selectedDuration = 'custom';
      this.showHoursDuration = true;
      this.updateCustomDuration();
      
      console.log('测试设置时长: 1小时30分钟');
      console.log('selectedDuration:', this.selectedDuration);
      console.log('showHoursDuration:', this.showHoursDuration);
      
      uni.showToast({
        title: '时长已设置为1.5小时',
        icon: 'success',
        duration: 1500
      });
    },
    
    // 快速选择截止时间（新方法）
    selectQuickDeadline(type, deadline) {
      console.log('选择截止时间:', type, deadline);
      
      if (type === 'normal') {
        this.selectedNormalDeadline = deadline.value;
        
        if (deadline.value !== 'custom') {
          // 选择预设截止时间
          const totalHours = parseFloat(deadline.value);
          
          if (totalHours >= 24) {
            // 大于等于24小时，转换为天数
            const days = Math.floor(totalHours / 24);
            const remainingHours = totalHours % 24;
            
            this.form.before_class_days = days.toString();
            this.form.before_class_hours = remainingHours.toString();
            this.showNormalDays = true;
          } else {
            // 小于24小时，只设置小时
            this.form.before_class_days = '';
            this.form.before_class_hours = totalHours.toString();
            this.showNormalDays = false;
          }
          
          this.form.before_class_minutes = '0';
          
          uni.showToast({
            title: `普通班截止时间已设置为${deadline.label}`,
            icon: 'success',
            duration: 1500
          });
        } else {
          // 选择自定义，保持当前数据或设置默认值
          if (!this.form.before_class_hours && !this.form.before_class_days) {
            this.form.before_class_hours = '3'; // 默认3小时
            this.form.before_class_minutes = '0';
            this.form.before_class_days = '';
            this.showNormalDays = false;
          } else {
            // 保持当前数据，根据是否有天数决定是否显示天数输入框
            this.showNormalDays = !!(this.form.before_class_days && parseInt(this.form.before_class_days) > 0);
          }
          
          uni.showToast({
            title: '可以自定义调整普通班截止时间',
            icon: 'none',
            duration: 1500
          });
        }
      } else if (type === 'vip') {
        this.selectedVipDeadline = deadline.value;
        
        if (deadline.value !== 'custom') {
          // 选择预设截止时间
          const totalHours = parseFloat(deadline.value);
          
          if (totalHours >= 24) {
            // 大于等于24小时，转换为天数
            const days = Math.floor(totalHours / 24);
            const remainingHours = totalHours % 24;
            
            this.form.boutique_before_class_days = days.toString();
            this.form.boutique_before_class_hours = remainingHours.toString();
            this.showVipDays = true;
          } else {
            // 小于24小时，只设置小时
            this.form.boutique_before_class_days = '';
            this.form.boutique_before_class_hours = totalHours.toString();
            this.showVipDays = false;
          }
          
          this.form.boutique_before_class_minutes = '0';
          
          uni.showToast({
            title: `精品班截止时间已设置为${deadline.label}`,
            icon: 'success',
            duration: 1500
          });
        } else {
          // 选择自定义，保持当前数据或设置默认值
          if (!this.form.boutique_before_class_hours && !this.form.boutique_before_class_days) {
            this.form.boutique_before_class_hours = '2'; // 默认2小时
            this.form.boutique_before_class_minutes = '0';
            this.form.boutique_before_class_days = '';
            this.showVipDays = false;
          } else {
            // 保持当前数据，根据是否有天数决定是否显示天数输入框
            this.showVipDays = !!(this.form.boutique_before_class_days && parseInt(this.form.boutique_before_class_days) > 0);
          }
          
          uni.showToast({
            title: '可以自定义调整精品班截止时间',
            icon: 'none',
            duration: 1500
          });
        }
      }
    },
    
    // 更新普通班截止时间
    updateNormalDeadline() {
      console.log('更新普通班截止时间');
      // 这里可以添加实时验证逻辑
    },
    
    // 更新精品班截止时间
    updateVipDeadline() {
      console.log('更新精品班截止时间');
      // 这里可以添加实时验证逻辑
    },
    
    // 切换普通班天数显示
    toggleNormalDays(e) {
      this.showNormalDays = e;
      if (!e) {
        this.form.before_class_days = '';
      }
    },
    
    // 切换精品班天数显示
    toggleVipDays(e) {
      this.showVipDays = e;
      if (!e) {
        this.form.boutique_before_class_days = '';
      }
    },
    
    // 新的星期选择方法 - 兼容移动端（增加过期验证）
    toggleWeekday(index) {
      console.log('切换星期选择:', this.weekList[index].text);
      
      // 获取当前选中状态
      const currentlySelected = this.selectedWeekdays[index];
      const newValue = !currentlySelected;
      
      // 如果是要选中这个星期，检查是否已过期
      if (newValue && this.form.startTime) {
        const weekdayValue = this.weekList[index].value;
        const isExpired = this.isWeekdayExpiredForFirstCycle(weekdayValue);
        
        // 检查是否启用了过期验证
        const validationEnabled = this.scheduleConfig?.validation?.enabled ?? true;
        const showWarningModal = this.scheduleConfig?.validation?.show_warning_modal ?? true;
        const allowNextWeekStart = this.scheduleConfig?.validation?.allow_next_week_start ?? true;
        
        if (isExpired && validationEnabled) {
          if (showWarningModal && allowNextWeekStart) {
            // 显示过期提示，但允许选择（会在后续周期生效）
            const weekdayName = this.weekList[index].text;
            uni.showModal({
              title: '提示',
              content: `本周的${weekdayName}已过，选择后将从下周开始生效。是否继续选择？`,
              confirmText: '继续选择',
              cancelText: '取消',
              success: (res) => {
                if (res.confirm) {
                  this.doToggleWeekday(index, newValue);
                }
              }
            });
            return;
          } else if (!allowNextWeekStart) {
            // 不允许下周开始，直接阻止选择
            const weekdayName = this.weekList[index].text;
            uni.showToast({
              title: `本周的${weekdayName}已过，不能选择`,
              icon: 'none',
              duration: 2000
            });
            return;
          }
        }
      }
      
      // 正常切换
      this.doToggleWeekday(index, newValue);
    },
    
    // 执行星期切换的具体逻辑
    doToggleWeekday(index, newValue) {
      // 切换选中状态
      this.$set(this.selectedWeekdays, index, newValue);
      
      // 重新计算选中的星期
      const weekdays = [];
      const weekdayNames = [];

      this.selectedWeekdays.forEach((selected, idx) => {
        if (selected) {
          weekdays.push(this.weekList[idx].value);
          weekdayNames.push(this.weekList[idx].text);
        }
      });

      // 更新表单数据
      this.form.weekdays = weekdays;
      this.form.weekDayName = weekdayNames.join('、');
      
      console.log('切换后选中星期:', this.form.weekDayName || '无');
      
      // 清除错误信息
      if (weekdays.length > 0) {
        this.clearError('weekdays');
      }
      
      // 触觉反馈（如果支持）
      try {
        uni.vibrateShort({
          type: 'light'
        });
      } catch (e) {
        // 忽略不支持的平台
      }
    },
    
    // 检查指定星期几在第一个周期是否已过期
    isWeekdayExpiredForFirstCycle(weekdayValue) {
      if (!this.form.startTime) {
        return false;
      }
      
      const startTime = new Date(this.form.startTime);
      const currentTime = new Date();
      
      // 如果开始时间本身就是未来时间，不需要检查
      if (startTime > currentTime) {
        return false;
      }
      
      // 计算这一周的指定星期几的时间
      const startWeekday = startTime.getDay(); // 0=周日, 1=周一, ..., 6=周六
      const targetWeekday = weekdayValue == 7 ? 0 : parseInt(weekdayValue); // 转换为Date格式的星期
      
      // 计算目标星期几距离开始时间的天数偏移
      let daysOffset = targetWeekday - startWeekday;
      if (daysOffset < 0) {
        daysOffset += 7; // 如果目标在下周，加7天
      }
      
      // 计算目标时间
      const targetTime = new Date(startTime);
      targetTime.setDate(targetTime.getDate() + daysOffset);
      
      // 检查目标时间是否已过期
      return targetTime < currentTime;
    },
    
    // 测试新的星期选择器
    testNewWeekdaySelector() {
      console.log('=== 测试新星期选择器 ===');
      
      // 模拟选择周一、周三、周五
      this.selectedWeekdays = [true, false, true, false, true, false, false];
      
      // 重新计算选中的星期
      const weekdays = [];
      const weekdayNames = [];

      this.selectedWeekdays.forEach((selected, idx) => {
        if (selected) {
          weekdays.push(this.weekList[idx].value);
          weekdayNames.push(this.weekList[idx].text);
        }
      });

      // 更新表单数据
      this.form.weekdays = weekdays;
      this.form.weekDayName = weekdayNames.join('、');
      
      console.log('测试选择结果:', this.form.weekDayName);
      console.log('weekdays数组:', this.form.weekdays);
      
      uni.showToast({
        title: `已选择：${this.form.weekDayName}`,
        icon: 'success',
        duration: 2000
      });
      
      console.log('=== 测试完成 ===');
    },

    // 高级配置开关事件处理方法
    
    /**
     * 虚拟人数开关变化处理
     */
    onVirtualEnabledChange(enabled) {
      console.log('虚拟人数开关变化:', enabled);
      
      // 同步到兼容字段
      this.form.virtualParticipants = enabled;
      
      if (enabled) {
        uni.showToast({
          title: '已启用虚拟人数功能',
          icon: 'success',
          duration: 1500
        });
      } else {
        uni.showToast({
          title: '已关闭虚拟人数功能',
          icon: 'none',
          duration: 1500
        });
      }
    },
    
    /**
     * 自动代扣开关变化处理
     */
    onAutoDeductionChange(enabled) {
      console.log('自动代扣开关变化:', enabled);
      
      // 只有周期班才能开启自动代扣
      if (enabled && this.form.classType !== '3') {
        uni.showToast({
          title: '只有周期班才能开启自动代扣',
          icon: 'none',
          duration: 2000
        });
        // 强制关闭
        this.$nextTick(() => {
          this.form.autoDeductionEnabled = false;
        });
        return;
      }
      
      if (enabled) {
        uni.showToast({
          title: '已启用自动代扣功能',
          icon: 'success',
          duration: 1500
        });
      } else {
        uni.showToast({
          title: '已关闭自动代扣功能',
          icon: 'none',
          duration: 1500
        });
      }
    },
    
    /**
     * 新人价开关同步处理
     * 班级级别的newUserPriceEnabled和排课级别的newbiePriceEnabled需要保持同步
     */
    syncNewbiePriceEnabled(enabled) {
      console.log('新人价开关变化:', enabled);
      
      // 同步到排课级别配置
      this.form.newbiePriceEnabled = enabled;
      
      // 同步到兼容字段
      this.form.newPriceEnabled = enabled;
      
      if (enabled) {
        uni.showToast({
          title: '已启用新人价功能',
          icon: 'success',
          duration: 1500
        });
      } else {
        uni.showToast({
          title: '已关闭新人价功能',
          icon: 'none',
          duration: 1500
        });
      }
    },
    
    /**
     * 班级类型变化时的配置联动处理
     */
    onClassTypeChange() {
      console.log('班级类型变化，当前类型:', this.form.classType);
      
      // 如果不是周期班，自动关闭自动代扣功能
      if (this.form.classType !== '3' && this.form.autoDeductionEnabled) {
        this.form.autoDeductionEnabled = false;
        console.log('非周期班，自动关闭自动代扣功能');
        
        uni.showToast({
          title: '定制班不支持自动代扣，已自动关闭',
          icon: 'none',
          duration: 2000
        });
      }
      
      // 定制班自动关闭新人价和新品价
      if (this.form.classType === '4') {
        const hasNewbieOrNewProduct = this.form.newUserPriceEnabled || this.form.newProductPriceEnabled;
        
        if (hasNewbieOrNewProduct) {
          this.form.newUserPriceEnabled = false;
          this.form.newbiePriceEnabled = false;
          this.form.newProductPriceEnabled = false;
          
          console.log('定制班自动关闭新人价和新品价');
          
          uni.showToast({
            title: '定制班不支持新人价和新品价，已自动关闭',
            icon: 'none',
            duration: 2000
          });
        }
      }
      
      // 同步到兼容字段
      this.form.virtualParticipants = this.form.virtualEnabled;
      this.form.newPriceEnabled = this.form.newUserPriceEnabled;
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background: #f5f5f5;
  padding-bottom: 120rpx;
}

/* 进度指示器样式 - 参考活动页面优化 */
.progress-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24rpx 32rpx;
  background: #ffffff;
  margin-bottom: 16rpx;
  border-radius: 8rpx;
  border: 1rpx solid #d5d5d5;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.progress-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18rpx;
  left: 60%;
  right: -40%;
  height: 2rpx;
  background: #d5d5d5;
  z-index: 1;
}

.progress-step.active:not(:last-child)::after,
.progress-step.completed:not(:last-child)::after {
  background: #0dc160;
}

.step-number {
  width: 36rpx;
  height: 36rpx;
  border-radius: 50%;
  background: #f5f5f5;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22rpx;
  font-weight: 500;
  margin-bottom: 8rpx;
  position: relative;
  z-index: 2;
  border: 1rpx solid #d5d5d5;
}

.progress-step.active .step-number {
  background: #0dc160;
  color: #ffffff;
  border-color: #0dc160;
}

.progress-step.completed .step-number {
  background: #0dc160;
  color: #ffffff;
  border-color: #0dc160;
}

.step-title {
  font-size: 24rpx;
  color: #666;
  text-align: center;
  font-weight: 400;
}

.progress-step.active .step-title,
.progress-step.completed .step-title {
  color: #0dc160;
  font-weight: 500;
}

/* 步骤内容样式 */
.step-content {
  padding: 0 20rpx;
}

.form-container {
  background: #ffffff;
  border-radius: 8rpx;
  overflow: hidden;
  border: 1rpx solid #d5d5d5;
}

.step-container {
  padding: 20rpx;
}

.step-header {
  text-align: center;
  margin-bottom: 30rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #d5d5d5;
}

.step-icon {
  font-size: 48rpx;
  margin-bottom: 12rpx;
}

.step-title-main {
  font-size: 32rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 8rpx;
}

.step-description {
  font-size: 24rpx;
  color: #666;
  line-height: 1.4;
}

/* 表单项样式 */
.form-item {
  margin-bottom: 30rpx;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: none;
}

.form-item:last-child {
  margin-bottom: 0;
}

.form-label {
  font-size: 28rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 10rpx;
  display: flex;
  align-items: center;
}

.form-label.required::after {
  content: '*';
  color: #ff4757;
  margin-left: 8rpx;
  font-size: 28rpx;
}

/* 班级类型选择器 */
.class-type-selector {
  display: flex;
  flex-direction: column;
  gap: 16rpx;
}

.class-type-item {
  display: flex;
  align-items: center;
  padding: 24rpx;
  background: #fff;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
  transition: all 0.3s ease;
}

.class-type-item.class-type-active {
  border-color: #0dc160;
  background: #f0fff4;
}

.radio-circle {
  width: 32rpx;
  height: 32rpx;
  border: 4rpx solid #e9ecef;
  border-radius: 50%;
  margin-right: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.class-type-active .radio-circle {
  border-color: #0dc160;
}

.radio-inner {
  width: 16rpx;
  height: 16rpx;
  background: #0dc160;
  border-radius: 50%;
}

.class-type-content {
  flex: 1;
}

.class-type-name {
  font-size: 30rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 4rpx;
}

.class-type-subtitle {
  font-size: 24rpx;
  color: #666;
  line-height: 1.4;
}

/* 简单输入框样式 */
.simple-input {
  padding: 10px;
  background: #ffffff;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 28rpx;
  color: #000000;
  transition: all 0.3s ease;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.simple-input:active {
  border-color: #0dc160;
}

/* 调试信息样式 */
.debug-time-info {
  margin-top: 16rpx;
  padding: 16rpx;
  background: #e3f2fd;
  border-radius: 8rpx;
  border: 1px solid #90caf9;
}

.debug-time-info text {
  display: block;
  font-size: 22rpx;
  color: #1976d2;
  margin-bottom: 4rpx;
}

/* 快速时间选择 */
.quick-time-select {
  margin-top: 16rpx;
}

.quick-time-label {
  font-size: 26rpx;
  color: #666;
  margin-bottom: 12rpx;
}

.quick-time-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

.quick-time-btn {
  padding: 12rpx 20rpx;
  background: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 20rpx;
  font-size: 24rpx;
  color: #666;
  text-align: center;
  transition: all 0.3s ease;
}

.quick-time-btn:active {
  background: #0dc160;
  border-color: #0dc160;
  color: #fff;
  transform: scale(0.95);
}

/* 快速时长选择样式 */
.quick-duration {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

.duration-chip {
  padding: 16rpx 24rpx;
  background: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 24rpx;
  font-size: 26rpx;
  color: #666;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.duration-chip.active {
  background: #0dc160;
  border-color: #0dc160;
  color: #fff;
}

.duration-chip:active {
  transform: scale(0.95);
}

/* 自定义时长样式 */
.custom-duration {
  padding: 24rpx;
  background: #f8f9fa;
  border-radius: 12rpx;
  border: 2rpx solid #e9ecef;
}

.duration-inputs {
  display: flex;
  gap: 24rpx;
  align-items: center;
}

.duration-input-group {
  display: flex;
  align-items: center;
  gap: 8rpx;
}

.duration-unit {
  font-size: 26rpx;
  color: #666;
  font-weight: 500;
  min-width: 60rpx;
}

/* 设置组样式 */
.setting-group {
  background: #ffffff;
  border-radius: 8rpx;
  padding: 20rpx;
  margin-bottom: 16rpx;
  border: 1rpx solid #d5d5d5;
}

.setting-title {
  display: flex;
  align-items: center;
  font-size: 28rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 20rpx;
  padding-bottom: 12rpx;
  border-bottom: 1rpx solid #d5d5d5;
}

.title-icon {
  font-size: 32rpx;
  margin-right: 8rpx;
}

.setting-row {
  margin-bottom: 20rpx;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  font-size: 28rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 10rpx;
}

/* 时间选择器样式优化 */
.time-quick-select {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

.time-chip {
  padding: 16rpx 24rpx;
  background: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 24rpx;
  font-size: 26rpx;
  color: #666;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.time-chip.active {
  background: #0dc160;
  border-color: #0dc160;
  color: #fff;
}

.time-chip:active {
  transform: scale(0.95);
}

/* 数字输入框样式 */
.number-range {
  display: flex;
  align-items: center;
  gap: 16rpx;
}

.number-input {
  display: flex;
  align-items: center;
  gap: 16rpx;
}

.range-separator,
.unit {
  font-size: 28rpx;
  color: #666;
  font-weight: 500;
}

/* 智能提示样式 */
.smart-tips {
  background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
  border-radius: 16rpx;
  padding: 24rpx;
  margin-top: 32rpx;
}

.tip-item {
  display: flex;
  align-items: flex-start;
}

.tip-icon {
  font-size: 32rpx;
  margin-right: 12rpx;
  margin-top: 4rpx;
}

.tip-text {
  font-size: 26rpx;
  color: #5e35b1;
  line-height: 1.5;
  flex: 1;
}

/* 表单部分样式 */
.form-section {
  background: #ffffff;
  border-radius: 8rpx;
  padding: 20rpx;
  margin-bottom: 16rpx;
  border: 1rpx solid #d5d5d5;
}

.form-section .form-item {
  margin-bottom: 30rpx;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.form-section .form-item:last-child {
  margin-bottom: 0;
}

.form-section .form-label {
  font-size: 28rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 10rpx;
  display: flex;
  align-items: center;
}

.form-section .form-label.required::after {
  content: '*';
  color: #ff4757;
  margin-left: 8rpx;
  font-size: 28rpx;
}

.form-input-wrapper {
  position: relative;
  background: #ffffff;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 10px 50rpx 10px 10px;
  transition: all 0.3s ease;
}

.form-input-wrapper:active {
  border-color: #0dc160;
}

.form-input {
  font-size: 28rpx;
  color: #000000;
  line-height: 1.4;
}

.form-input.placeholder {
  color: rgb(192, 196, 204);
}

.form-input.disabled {
  color: #ccc;
  opacity: 0.6;
}

.form-arrow {
  position: absolute;
  right: 20rpx;
  top: 50%;
  transform: translateY(-50%);
}

.form-input-field {
  background: transparent;
  border: none;
  font-size: 28rpx;
  color: #333;
}

.error-text {
  font-size: 24rpx;
  color: #ff4757;
  margin-top: 8rpx;
  line-height: 1.4;
}

/* 周期选择器优化 */
.form-section .weekdays-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;
  padding: 20rpx;
  background: #f8f9fa;
  border-radius: 12rpx;
  border: 2rpx solid #e9ecef;
}

.form-section .weekday-item {
  flex: 0 0 auto;
}

.checkbox-selected {
  color: #0dc160 !important;
}

/* 高级设置样式 */
.advanced-setting {
  background: #ffffff;
  border-radius: 8rpx;
  padding: 20rpx;
  margin-bottom: 16rpx;
  border: 1rpx solid #d5d5d5;
}

/* 配置说明样式 */
.config-tips {
  background: linear-gradient(135deg, #e8f5e8 0%, #f0f8ff 100%);
  border-radius: 16rpx;
  padding: 24rpx;
  margin-top: 32rpx;
  border: 2rpx solid #c8e6c9;
}

.tips-title {
  font-size: 28rpx;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 16rpx;
  display: flex;
  align-items: center;
}

.tips-content {
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.tips-content text {
  font-size: 24rpx;
  color: #1b5e20;
  line-height: 1.6;
  padding-left: 8rpx;
}

.tips-content text::before {
  content: '';
  display: inline-block;
  width: 4rpx;
  height: 4rpx;
  background: #4caf50;
  border-radius: 50%;
  margin-right: 8rpx;
  vertical-align: middle;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16rpx 0;
  border-bottom: 1rpx solid #d5d5d5;
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item.setting-disabled {
  opacity: 0.6;
}

.setting-item.setting-disabled .setting-label,
.setting-item.setting-disabled .setting-desc {
  color: #999 !important;
}

.setting-info {
  flex: 1;
}

.setting-info .setting-label {
  font-size: 28rpx;
  font-weight: 500;
  color: #000000;
  margin-bottom: 4rpx;
}

.setting-desc {
  font-size: 24rpx;
  color: #666;
  line-height: 1.4;
}

/* 完成提示样式 */
.completion-tips {
  background: #f0fff4;
  border-radius: 8rpx;
  padding: 20rpx;
  margin-top: 20rpx;
  display: flex;
  align-items: center;
  border: 1rpx solid #c8e6c9;
}

.completion-icon {
  font-size: 40rpx;
  margin-right: 16rpx;
}

.completion-text {
  flex: 1;
}

.completion-text .completion-title {
  font-size: 28rpx;
  font-weight: 500;
  color: #0dc160;
  margin-bottom: 4rpx;
}

.completion-text .completion-desc {
  font-size: 24rpx;
  color: #52c41a;
  line-height: 1.4;
}

/* 底部操作按钮 */
.action-buttons {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 24rpx;
  padding: 20rpx;
  background: #ffffff;
  border-top: 1rpx solid #d5d5d5;
  z-index: 100;
}

.btn {
  width: 331rpx;
  height: 90rpx;
  border-radius: 44rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
}

.btn-secondary {
  background: #fcfffe;
  color: #333;
  border: 2rpx solid #d5d5d5;
}

.btn-secondary:active {
  background: #f0f0f0;
  transform: scale(0.98);
}

.btn-primary {
  background: #0dc160;
  color: #ffffff;
}

.btn-primary:active {
  background: #0ba94d;
  transform: scale(0.98);
}

/* 成功弹窗样式 */
.success-popup {
  padding: 48rpx 32rpx;
  text-align: center;
  background: #fff;
  border-radius: 16rpx;
}

.success-icon {
  margin-bottom: 24rpx;
}

.success-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 16rpx;
}

.success-desc {
  font-size: 28rpx;
  color: #666;
  line-height: 1.5;
  margin-bottom: 40rpx;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 16rpx;
}

.success-btn {
  height: 88rpx;
  border-radius: 44rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
  font-weight: 600;
  transition: all 0.3s ease;
}

.success-btn.primary {
  background: #0dc160;
  color: #fff;
}

.success-btn.default {
  background: #f8f9fa;
  color: #666;
  border: 2rpx solid #e9ecef;
}

.success-btn.link {
  background: transparent;
  color: #0dc160;
  border: 2rpx solid #0dc160;
}

.success-btn:active {
  transform: scale(0.98);
}

/* 测试内容样式 */
.test-content {
  padding: 24rpx;
  background: #fff3cd;
  border: 2rpx solid #ffeaa7;
  border-radius: 12rpx;
  margin-bottom: 24rpx;
}

.test-content text {
  display: block;
  font-size: 26rpx;
  color: #856404;
  margin-bottom: 8rpx;
}

.test-content text:last-child {
  margin-bottom: 0;
}

/* 测试按钮样式 */
.test-btn {
  padding: 8rpx 16rpx;
  border-radius: 16rpx;
  font-size: 22rpx;
  text-align: center;
  transition: all 0.3s ease;
}

.test-btn:active {
  transform: scale(0.95);
}

/* 时长输入样式 */
.duration-section {
  margin-bottom: 20rpx;
  padding: 20rpx;
  background: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
}

.duration-label {
  font-size: 26rpx;
  color: #333;
  font-weight: 500;
  margin-bottom: 12rpx;
}

.duration-checkbox-row {
  margin-bottom: 12rpx;
}

.duration-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12rpx;
}

.duration-unit {
  font-size: 26rpx;
  color: #666;
  font-weight: 500;
  min-width: 60rpx;
}

.quick-duration {
  margin-top: 20rpx;
  padding: 20rpx;
  background: #fff;
  border: 2rpx solid #e9ecef;
  border-radius: 12rpx;
}

.quick-duration-label {
  font-size: 26rpx;
  color: #666;
  margin-bottom: 12rpx;
}

.duration-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

/* 班级类型说明样式 */
.class-type-description {
  margin-top: 24rpx;
  padding: 24rpx;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12rpx;
  border: 2rpx solid #dee2e6;
}

.type-desc {
  text-align: left;
}

.desc-title {
  font-size: 28rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 16rpx;
  display: flex;
  align-items: center;
}

.desc-content {
  display: flex;
  flex-direction: column;
  gap: 16rpx;
}

.desc-section {
  background: rgba(255, 255, 255, 0.6);
  padding: 16rpx;
  border-radius: 8rpx;
  border-left: 4rpx solid #0dc160;
}

.desc-section-title {
  font-size: 26rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 8rpx;
}

.desc-content text {
  font-size: 24rpx;
  color: #666;
  line-height: 1.6;
  display: block;
  margin-bottom: 4rpx;
}

.desc-content text:last-child {
  margin-bottom: 0;
}

/* 截止时间选择器样式 */
.deadline-quick-select {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

.deadline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12rpx;
}

.deadline-chip {
  padding: 16rpx 24rpx;
  background: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 24rpx;
  font-size: 26rpx;
  color: #666;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.deadline-chip.active {
  background: #0dc160;
  border-color: #0dc160;
  color: #fff;
}

.deadline-chip:active {
  transform: scale(0.95);
}

/* 自定义截止时间样式 */
.custom-deadline {
  padding: 24rpx;
  background: #f8f9fa;
  border-radius: 12rpx;
  border: 2rpx solid #e9ecef;
}

.deadline-inputs {
  display: flex;
  gap: 24rpx;
  align-items: center;
  flex-wrap: wrap;
}

.deadline-input-group {
  display: flex;
  align-items: center;
  gap: 8rpx;
}

.deadline-unit {
  font-size: 26rpx;
  color: #666;
  font-weight: 500;
  min-width: 60rpx;
}

/* 截止时间显示 */
.deadline-display {
  margin-top: 16rpx;
  padding: 16rpx;
  background: #e8f5e8;
  border-radius: 8rpx;
  border: 1rpx solid #c8e6c9;
}

.deadline-display-label {
  font-size: 24rpx;
  color: #2e7d32;
  font-weight: 500;
}

.deadline-display-value {
  font-size: 24rpx;
  color: #1b5e20;
  font-weight: 600;
}

/* 表单标签描述 */
.form-label-desc {
  font-size: 24rpx;
  color: #666;
  margin-bottom: 10rpx;
  line-height: 1.4;
}

/* 优化的星期选择器 - 兼容移动端 */
.weekdays-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;
  padding: 20rpx;
  background: #f8f9fa;
  border-radius: 12rpx;
  border: 2rpx solid #e9ecef;
}

.weekday-option {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 16rpx;
  background: #fff;
  border: 2rpx solid #e9ecef;
  border-radius: 8rpx;
  transition: all 0.3s ease;
  cursor: pointer;
}

.weekday-option.weekday-selected {
  border-color: #0dc160;
  background: #f0fff4;
}

.weekday-circle {
  width: 24rpx;
  height: 24rpx;
  border-radius: 50%;
  margin-right: 8rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weekday-check {
  width: 16rpx;
  height: 16rpx;
  background: #0dc160;
  border-radius: 50%;
}

.weekday-text {
  font-size: 26rpx;
  color: #666;
}

/* 选择结果显示 */
.selected-weekdays {
  margin-top: 16rpx;
  padding: 16rpx;
  background: #e8f5e8;
  border-radius: 8rpx;
  border: 1rpx solid #c8e6c9;
}

.selected-label {
  font-size: 24rpx;
  color: #2e7d32;
  font-weight: 500;
  margin-right: 8rpx;
}

.selected-value {
  font-size: 24rpx;
  color: #1b5e20;
  font-weight: 600;
}

/* 测试按钮样式 */
.test-btn {
  padding: 8rpx 16rpx;
  border-radius: 16rpx;
  font-size: 22rpx;
  text-align: center;
  transition: all 0.3s ease;
}

.test-btn:active {
  transform: scale(0.95);
}

/* 测试新星期选择器 */
.test-btn.test-new-weekday-selector {
  background: #4caf50;
  color: #fff;
}

.class-type-content {
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.class-type-name {
  font-size: 28rpx;
  font-weight: 600;
  color: #333;
}

.class-type-subtitle {
  font-size: 24rpx;
  color: #666;
}
</style>
